Subject |
Re: Pushbuttons |
From |
Mervyn Bick <invalid@invalid.invald> |
Date |
Mon, 7 Oct 2019 15:54:24 +0200 |
Newsgroups |
dbase.getting-started |
On 2019-10-07 8:05 AM, Akshat Kapoor wrote:
> Thank You for the explanation Mervyn,
> Yes extracting what to do from Pushbutton properties is also possible
> We can easily obtain which control has focus
>
> if type('this.parent.activeControl') # 'U'
> if this.parent.activeControl.Name == "CANCELPUSHBUTTON"
> this.stopTrying := true
> return
> endif
> endif
>
It's actually easier than that. Store the value from the field
push_action to a user-defined property of the pushbutton when it is
constructed
cmd = [form.main]+temp+[.action = ']+
rtrim(form.table1.rowset.fields["push_action"].value)+[']
&cmd
cmd = [form.main]+temp+[.onclick = form.push_onclick]
&cmd
All the pushbuttons use the same onClick event handler but you don't
need to know specifically which pushbutton has focus. In fact, if you
set the pushbutton's speedbar property true, it won't get focus when
clicked.
"this" in the event handler is always the object which executed the
event handler whether it gets focus or not. The event handler can,
instead of having the action passed to it as a parameter, simply fetch
it from the user-defined property of the appropriate pushbutton.
function push_onClick()
action = this.action
form.result.text = action
....
return
Mervyn.
|
|