Skip to content

Commit 98f12f2

Browse files
committed
app: [macos] set focus on click
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
1 parent e863903 commit 98f12f2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

app/os_macos.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ static void invalidateCharacterCoordinates(CFTypeRef viewRef) {
217217
}
218218
}
219219
}
220+
221+
static void setFocus(CFTypeRef windowRef, CFTypeRef viewRef) {
222+
NSWindow *window = (__bridge NSWindow *)windowRef;
223+
NSView *view = (__bridge NSView *)viewRef;
224+
[window makeFirstResponder:view];
225+
}
226+
220227
*/
221228
import "C"
222229

@@ -539,6 +546,11 @@ func gio_onMouse(view, evt C.CFTypeRef, cdir C.int, cbtns C.NSUInteger, x, y, dx
539546
if cbtns&(1<<2) != 0 {
540547
btns |= pointer.ButtonTertiary
541548
}
549+
550+
if typ == pointer.Press {
551+
C.setFocus(w.window, w.view)
552+
}
553+
542554
w.w.Event(pointer.Event{
543555
Type: typ,
544556
Source: pointer.Mouse,

0 commit comments

Comments
 (0)