|
Pages: [1]
|
 |
|
Author
|
Topic: Can a button press be simulated? (Read 765 times)
|
|
Thør
|
Hello everyone! Another question from someone who's weaning away from traditional Windoze programming  ; Is there a way to simulate a button press? So that hitting Enter after I type something in the text-field would not just lose the focus on the field, but also select and "click" the OK button. Thank you for your response.
|
|
|
|
|
Logged
|
|
|
|
|
henrikmk
|
It's not an actual mouse event, but you can say:
view layout [b: button "Hello!" [print "hello!"]]
do-face b none
This will do the action defined for the button.
|
|
|
|
|
Logged
|
|
|
|
|
Thør
|
henrikmk, Thanks, I was actually looking for something like the following: btn "Send" #"^S" [submit]
|
|
|
|
|
Logged
|
|
|
|
|
Anton
|
Well, if you're talking about a field, how about this:
view layout [my-field: field [print value] btn "Send" [print my-field/text]]
Did you actually want the field action to cause the btn to change visual state as well ? That's a little more tricky, but can be done.
With a few helper functions, you can simulate mouse clicks:
depress-face: func [face][face/feel/engage face 'down none] ; causes action in some gadgets release-face: func [face][face/feel/engage face 'up none] ; causes action in buttons click-face: func [face][depress-face face release-face face] ; depress and release restore-face: func [face][face/state: off show face]
view layout [my-btn: btn "Send" [print value] btn "click-face" [click-face my-btn restore-face face]]
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |