Skip to content

Commit b05811f

Browse files
committed
fix: cand box out of screen
still buggy if the box go out of screen after typing some words
1 parent dff27f1 commit b05811f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Rabbit.ahk

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,21 @@ ProcessKey(key, mask, this_hotkey) {
234234
max_width := 150
235235

236236
if caret {
237+
workspace_width := SysGet(16) ; SM_CXFULLSCREEN
238+
workspace_height := SysGet(17) ; SM_CYFULLSCREEN
237239
box["Preedit"].Value := preedit_text
238240
box["Candidates"].Value := menu_text
239241
box["Preedit"].Move(, , max_width)
240242
box["Candidates"].Move(, , max_width, height * candidate_text_array.Length)
241243
box.Show("Hide")
242-
box.Show("AutoSize NA x" . (caret_x + caret_w) . " y" . (caret_y + caret_h + 4))
244+
box.GetPos(, , &box_width, &box_height)
245+
new_x := caret_x + caret_w
246+
new_y := caret_y + caret_h + 4
247+
if new_x + box_width > workspace_width
248+
new_x := workspace_width - box_width
249+
if new_y + box_height > workspace_height
250+
new_y := caret_y - 4 - box_height
251+
box.Show("AutoSize NA x" . new_x . " y" . new_y)
243252
WinSetAlwaysOnTop(1, box)
244253
} else {
245254
ToolTip(preedit_text . "`r`n" . menu_text)

0 commit comments

Comments
 (0)