Skip to content

Commit

Permalink
Merge pull request #363 from spyoungtech/fix-tooltip-v2
Browse files Browse the repository at this point in the history
fix show_tooltip for AHK v2
spyoungtech authored Jan 15, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents a6e7a0f + caadd3a commit b2e9f5d
Showing 5 changed files with 24 additions and 14 deletions.
14 changes: 6 additions & 8 deletions ahk/_async/transport.py
Original file line number Diff line number Diff line change
@@ -321,8 +321,7 @@ async def run_script(self, script_text_or_path: str, /, *, blocking: bool = True
@abstractmethod
async def run_script(
self, script_text_or_path: str, /, *, blocking: bool = True, timeout: Optional[int] = None
) -> Union[str, AsyncFutureResult[str]]:
return NotImplemented
) -> Union[str, AsyncFutureResult[str]]: ...

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

@abstractmethod # unasync: remove
async def a_send_nonblocking( # unasync: remove
self, request: RequestMessage, engine: Optional[AsyncAHK[Any]] = None
) -> AsyncFutureResult[
Union[None, Tuple[int, int], int, str, bool, AsyncWindow, List[AsyncWindow], List[AsyncControl]]
]:
return NotImplemented
]: ...

@abstractmethod
def send_nonblocking(
self, request: RequestMessage, engine: Optional[AsyncAHK[Any]] = None
) -> FutureResult[Union[None, Tuple[int, int], int, str, bool, AsyncWindow, List[AsyncWindow], List[AsyncControl]]]:
return NotImplemented
) -> FutureResult[
Union[None, Tuple[int, int], int, str, bool, AsyncWindow, List[AsyncWindow], List[AsyncControl]]
]: ...


class AsyncDaemonProcessTransport(AsyncTransport):
8 changes: 7 additions & 1 deletion ahk/_constants.py
Original file line number Diff line number Diff line change
@@ -5704,7 +5704,13 @@
x := args[2]
y := args[3]
which := args[4]
ToolTip(text, x, y, which)
ToolTip(text, IsNumber(x) ? Number(x) : unset, IsNumber(y) ? Number(y) : unset, which || unset)
; In AHK v2, doubling the call to ToolTip seems necessary to ensure synchronous creation of the window
; This seems to be more reliable than sleeping to wait for the tooltip callback
; Without this doubled up call (or a sleep) we return the the blocking loop (awaiting next command from Python)
; before the tooltip window is created, meaning the tooltip will not show until if/when processing the next command
ToolTip(text, IsNumber(x) ? Number(x) : unset, IsNumber(y) ? Number(y) : unset, which || unset)
return FormatNoValueResponse()
{% endblock AHKShowToolTip %}
}
6 changes: 3 additions & 3 deletions ahk/_sync/transport.py
Original file line number Diff line number Diff line change
@@ -293,7 +293,7 @@ def run_script(self, script_text_or_path: str, /, *, blocking: bool = True, time
def run_script(
self, script_text_or_path: str, /, *, blocking: bool = True, timeout: Optional[int] = None
) -> Union[str, FutureResult[str]]:
return NotImplemented
...

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


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


class DaemonProcessTransport(Transport):
8 changes: 7 additions & 1 deletion ahk/templates/daemon-v2.ahk
Original file line number Diff line number Diff line change
@@ -2691,7 +2691,13 @@ AHKShowToolTip(args*) {
x := args[2]
y := args[3]
which := args[4]
ToolTip(text, x, y, which)

ToolTip(text, IsNumber(x) ? Number(x) : unset, IsNumber(y) ? Number(y) : unset, which || unset)
; In AHK v2, doubling the call to ToolTip seems necessary to ensure synchronous creation of the window
; This seems to be more reliable than sleeping to wait for the tooltip callback
; Without this doubled up call (or a sleep) we return the the blocking loop (awaiting next command from Python)
; before the tooltip window is created, meaning the tooltip will not show until if/when processing the next command
ToolTip(text, IsNumber(x) ? Number(x) : unset, IsNumber(y) ? Number(y) : unset, which || unset)
return FormatNoValueResponse()
{% endblock AHKShowToolTip %}
}
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ unasync
black
tokenize-rt
coverage
mypy==1.13.0
mypy
typing_extensions
jinja2
pytest-rerunfailures

0 comments on commit b2e9f5d

Please sign in to comment.