Skip to content

Commit b2e9f5d

Browse files
authored
Merge pull request #363 from spyoungtech/fix-tooltip-v2
fix show_tooltip for AHK v2
2 parents a6e7a0f + caadd3a commit b2e9f5d

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

ahk/_async/transport.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@ async def run_script(self, script_text_or_path: str, /, *, blocking: bool = True
321321
@abstractmethod
322322
async def run_script(
323323
self, script_text_or_path: str, /, *, blocking: bool = True, timeout: Optional[int] = None
324-
) -> Union[str, AsyncFutureResult[str]]:
325-
return NotImplemented
324+
) -> Union[str, AsyncFutureResult[str]]: ...
326325

327326
# fmt: off
328327
@overload
@@ -565,22 +564,21 @@ async def function_call(
565564
@abstractmethod
566565
async def send(
567566
self, request: RequestMessage, engine: Optional[AsyncAHK[Any]] = None
568-
) -> Union[None, Tuple[int, int], int, str, bool, AsyncWindow, List[AsyncWindow], List[AsyncControl]]:
569-
return NotImplemented
567+
) -> Union[None, Tuple[int, int], int, str, bool, AsyncWindow, List[AsyncWindow], List[AsyncControl]]: ...
570568

571569
@abstractmethod # unasync: remove
572570
async def a_send_nonblocking( # unasync: remove
573571
self, request: RequestMessage, engine: Optional[AsyncAHK[Any]] = None
574572
) -> AsyncFutureResult[
575573
Union[None, Tuple[int, int], int, str, bool, AsyncWindow, List[AsyncWindow], List[AsyncControl]]
576-
]:
577-
return NotImplemented
574+
]: ...
578575

579576
@abstractmethod
580577
def send_nonblocking(
581578
self, request: RequestMessage, engine: Optional[AsyncAHK[Any]] = None
582-
) -> FutureResult[Union[None, Tuple[int, int], int, str, bool, AsyncWindow, List[AsyncWindow], List[AsyncControl]]]:
583-
return NotImplemented
579+
) -> FutureResult[
580+
Union[None, Tuple[int, int], int, str, bool, AsyncWindow, List[AsyncWindow], List[AsyncControl]]
581+
]: ...
584582

585583

586584
class AsyncDaemonProcessTransport(AsyncTransport):

ahk/_constants.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5704,7 +5704,13 @@
57045704
x := args[2]
57055705
y := args[3]
57065706
which := args[4]
5707-
ToolTip(text, x, y, which)
5707+
5708+
ToolTip(text, IsNumber(x) ? Number(x) : unset, IsNumber(y) ? Number(y) : unset, which || unset)
5709+
; In AHK v2, doubling the call to ToolTip seems necessary to ensure synchronous creation of the window
5710+
; This seems to be more reliable than sleeping to wait for the tooltip callback
5711+
; Without this doubled up call (or a sleep) we return the the blocking loop (awaiting next command from Python)
5712+
; before the tooltip window is created, meaning the tooltip will not show until if/when processing the next command
5713+
ToolTip(text, IsNumber(x) ? Number(x) : unset, IsNumber(y) ? Number(y) : unset, which || unset)
57085714
return FormatNoValueResponse()
57095715
{% endblock AHKShowToolTip %}
57105716
}

ahk/_sync/transport.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def run_script(self, script_text_or_path: str, /, *, blocking: bool = True, time
293293
def run_script(
294294
self, script_text_or_path: str, /, *, blocking: bool = True, timeout: Optional[int] = None
295295
) -> Union[str, FutureResult[str]]:
296-
return NotImplemented
296+
...
297297

298298
# fmt: off
299299
@overload
@@ -537,14 +537,14 @@ def function_call(
537537
def send(
538538
self, request: RequestMessage, engine: Optional[AHK[Any]] = None
539539
) -> Union[None, Tuple[int, int], int, str, bool, Window, List[Window], List[Control]]:
540-
return NotImplemented
540+
...
541541

542542

543543
@abstractmethod
544544
def send_nonblocking(
545545
self, request: RequestMessage, engine: Optional[AHK[Any]] = None
546546
) -> FutureResult[Union[None, Tuple[int, int], int, str, bool, Window, List[Window], List[Control]]]:
547-
return NotImplemented
547+
...
548548

549549

550550
class DaemonProcessTransport(Transport):

ahk/templates/daemon-v2.ahk

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2691,7 +2691,13 @@ AHKShowToolTip(args*) {
26912691
x := args[2]
26922692
y := args[3]
26932693
which := args[4]
2694-
ToolTip(text, x, y, which)
2694+
2695+
ToolTip(text, IsNumber(x) ? Number(x) : unset, IsNumber(y) ? Number(y) : unset, which || unset)
2696+
; In AHK v2, doubling the call to ToolTip seems necessary to ensure synchronous creation of the window
2697+
; This seems to be more reliable than sleeping to wait for the tooltip callback
2698+
; Without this doubled up call (or a sleep) we return the the blocking loop (awaiting next command from Python)
2699+
; before the tooltip window is created, meaning the tooltip will not show until if/when processing the next command
2700+
ToolTip(text, IsNumber(x) ? Number(x) : unset, IsNumber(y) ? Number(y) : unset, which || unset)
26952701
return FormatNoValueResponse()
26962702
{% endblock AHKShowToolTip %}
26972703
}

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ unasync
44
black
55
tokenize-rt
66
coverage
7-
mypy==1.13.0
7+
mypy
88
typing_extensions
99
jinja2
1010
pytest-rerunfailures

0 commit comments

Comments
 (0)