一般情况下,你不需要了解这些内容。
在极少数情况下,你的app可能需要去获取用户按下的按键信息,比如盗号木马 开发一款输入法。只有这样你才能给用户提供候选。
怎么在 macOS 下创建一个输入法,我在Swift 使用 InputMethodKit 写输入法这篇文章中有详细的说明,这里略过[……]
一般情况下,你不需要了解这些内容。
在极少数情况下,你的app可能需要去获取用户按下的按键信息,比如盗号木马 开发一款输入法。只有这样你才能给用户提供候选。
怎么在 macOS 下创建一个输入法,我在Swift 使用 InputMethodKit 写输入法这篇文章中有详细的说明,这里略过[……]
最近做 Windows 上的项目,客户要求要做的“炫”一点,所以,动态的窗口背景永远是必不可少的内容(比如手机qq的登录界面对吧?
我本以为这是一个很容易实现的功能于是就满口答应下来……是的,在 winform 里,并不是那么容易就能达到你想要的效果的。
理所当然,我们想到如果要播放视频[……]
在开发落格输入法 macOS 版本的时候,我遇到了这么一个难题,那就是窗口优先级的问题。在之前 如何让 NSWindow 显示在不同的 Space 或者 Screen 中 这篇文章中我提到了自己实现了落格输入法的候选栏,其实是用一个 NSWindow
在开发落格输入法的时候,我遇到了这么一件事情,就是作为候选栏的窗口会在屏幕边缘的时候超出屏幕去!所以,在显示窗口的时候我根据坐标做了额外的检查:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
if visiableCandidateCells.isEmpty { if let screenframe = NSScreen.main?.visibleFrame { if screenframe.width < location.x + size.width { location.x -= location.x + size.width - screenframe.width } } } else { if let screenframe = NSScreen.main?.visibleFrame { if screenframe.width < location.x + self.window!.frame.size.width { location.x -= location.x + self.window!.frame.size.width - screenframe.width } } } if location.y < 50 { location.y += 35 + 35 } |
总之,就是说如果坐标算上自己的宽度超过了屏幕的宽度,就把它挪回来。
但是,这样[……]
在写落格输入法 Mac 版的过程当中,我遇到了这么一个问题,系统的候选条 API 年久失修,很多功能 API 存在但根本无效,比如:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
/*! @method @abstract Sets the "style" attributes for the candidates window. The keys for the attributes dictionary and the values are: NSFontAttributeName (value = NSFont) Setting the font attribute sets the font that is used to draw Candidates. It does not effect the selection keys which are always drawn in the same font. Note that to set the font size you should use this key/value pair. IMKCandidatesOpacityAttributeName (value = NSNumber with a float value between 0 and 1). Sets the opacity level to transparent (0.0) to completely opaque (1.0). The default opacity is 1.0. This constant is declared above. NSForegroundColorAttributeName (value = NSColor) Sets the text color used for the candidate text. By default it is black. NSBackgroundColorDocumentAttribute (value = NSColor). Set the background color that is drawn behind the candidate text. IMKCandidatesSendServerKeyEventFirst (value = NSNumber). NO (default) gives the candidate window first chance at key events. YES causes events to first be routed to the current IMKInputController. In that case, if the event is not handled, it will then be sent to the candidate window. */ open func setAttributes(_ attributes: [AnyHashable : Any]!) |
这个方法是用来设置候选条风格的,里边除了默认的[crayon-662c023627b731103[……]
在 Swift 中,大家经常会用 URL 来初始化一个路径,比如网页的链接。比如这样:
1 2 3 4 5 6 |
…… @IBAction func goToWeb(_ sender: NSButton) { let url = URL(string: "https://v2mm.tech/category/80/logcg-input-method") NSWorkspace.shared.open(url!) } …… |
当用户点击按钮(比如说这个帮助按钮),那么一下子就帮用户打开默认的浏览器,并打开指定的页面(这里是个论坛)。
那么,如果你的链接是这样的[……]
Gradle 默认直连网络,即使 Mac 设置了全局代理也是一样。就算你给 Android Studio 设置了代理,它依旧会风轻云淡地直连那个你在中国一辈子也不可能连上的网站……
要让 Gradle 走代理,你需要给它进行单独的配置,在每个项目的 [crayon-662c02362882a8[……]