Skip to content

Commit

Permalink
app: [macos] set focus on click
Browse files Browse the repository at this point in the history
Signed-off-by: Inkeliz <[email protected]>
  • Loading branch information
inkeliz committed Jul 25, 2022
1 parent 26e7101 commit bffdabf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/os_macos.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ static void invalidateCharacterCoordinates(CFTypeRef viewRef) {
}
}
}
static void setFocus(CFTypeRef windowRef, CFTypeRef viewRef) {
NSWindow *window = (__bridge NSWindow *)windowRef;
NSView *view = (__bridge NSView *)viewRef;
[window makeFirstResponder:view];
}
*/
import "C"

Expand Down Expand Up @@ -539,6 +546,11 @@ func gio_onMouse(view, evt C.CFTypeRef, cdir C.int, cbtns C.NSUInteger, x, y, dx
if cbtns&(1<<2) != 0 {
btns |= pointer.ButtonTertiary
}

if typ == pointer.Press {
C.setFocus(w.window, w.view)
}

w.w.Event(pointer.Event{
Type: typ,
Source: pointer.Mouse,
Expand Down

0 comments on commit bffdabf

Please sign in to comment.