Rebol Talk Forum  |  REBOL Discussions  |  REBOL View  |  Topic: Can a button press be simulated?
Pages: [1] Print
Author Topic: Can a button press be simulated?  (Read 765 times)
Thør
Newbie
*
Offline Offline

Posts: 46


View Profile
Can a button press be simulated?
« on: July 15, 2006, 01:05:01 PM »

Hello everyone!

Another question from someone who's weaning away from traditional Windoze programming Cheesy;

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
Newbie
*
Offline Offline

Posts: 49


View Profile
Re: Can a button press be simulated?
« Reply #1 on: July 16, 2006, 09:40:57 AM »

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
Newbie
*
Offline Offline

Posts: 46


View Profile
Re: Can a button press be simulated?
« Reply #2 on: August 06, 2006, 04:30:52 PM »

henrikmk,

Thanks, I was actually looking for something like the following:

Code:
btn "Send" #"^S" [submit]

Logged
Anton
Jr. Member
**
Offline Offline

Posts: 65

Rebol veteran


View Profile WWW
Re: Can a button press be simulated?
« Reply #3 on: August 20, 2006, 12:40:27 PM »

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] Print 
Rebol Talk Forum  |  REBOL Discussions  |  REBOL View  |  Topic: Can a button press be simulated?
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 08, 2008, 02:25:04 AM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2245 Posts in 589 Topics by 2259 Members
Latest Member: edibritrava

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc