一般情況下,你不需要了解這些內容。
在極少數情況下,你的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-6637db9b957b63805[……]
在 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-6637db9b95e383[……]