Skip to content

Instantly share code, notes, and snippets.

@DideC
Created October 19, 2016 08:37
Show Gist options
  • Save DideC/fb8143eaca5f5bfe03e7722ec23e336c to your computer and use it in GitHub Desktop.
Save DideC/fb8143eaca5f5bfe03e7722ec23e336c to your computer and use it in GitHub Desktop.
Tiny VID utility func and test (find-window, focus)
Red [
title: "Test of `find-window and `focus funcs"
author: "Didier Cadieu"
]
find-window: func [
"Find a face's window face."
face [object!]
][
while [face/parent] [face: face/parent]
face
]
focus: func [
"Set the focus to the face"
face [object!]
/local win
][
if win: find-window face [win/selected: face]
]
; TESTS
w1: view/no-wait/options [
text "Test focus"
f1: field
f2: field
f3: field
button "f1" [focus f1]
button "f2" [focus f2]
button "f3" [focus f3]
] [offset: 100x100]
w2: view/no-wait/options [
f4: field
f5: field
f6: field
button "f1" [focus f1]
button "f4" [focus f4]
button "f5" [focus f5]
button "f6" [focus f6]
] [offset: 100x200]
do-events
@koba-yu
Copy link

koba-yu commented Jan 5, 2017

This is the code that I have been looking for recently, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment