Discussion:
Pushbutton Default in modal forms
(too old to reply)
Garry Christensen
2004-02-15 23:43:10 UTC
Permalink
I don't know if this has been reported. I have a form that is instantiated
at the beginning of an app but only opened as I need it. It has an OK
button set as Default. I use it modal, opening it with readmodal().
I can press enter and the OK button fires, then closes the form. I can open
it again and repeat this as many times as I like. If I tab to the OK button
and press enter, the form closes as it should but on all subsequent uses,
the button refuses to respond to the Enter key, either as default or when it
has focus.

Here's a demo:
Run it the first time to instantiate it and press Enter to close it.
Run it again and tab to the button and press Enter.
Run it again and try to close it by pressing Enter. The button no longer
responds.
(watch for wordwrap)

************************************

if type('_app.PushbuttonDefault') = 'U'
_app.PushbuttonDefault = new pushbuttonDefaultForm()
endif
_app.PushbuttonDefault.readModal()
if _app.PushbuttonDefault.OpenCount = 3
_app.PushbuttonDefault = null
endif

**************************************

class pushbuttonDefaultForm of FORM
with (this)
onOpen = class::FORM_ONOPEN
height = 4
width = 75
mdi = false
endwith

this.ENTRYFIELD1 = new ENTRYFIELD(this)
with (this.ENTRYFIELD1)
height = 1
left = 1.
top = 0.4
width = 72
endwith

this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onClick = {;form.close()}
height = 1
left = 26
top = 2
width = 15
text = "Close"
default = true
endwith


function form_onOpen
do case
case type('form.OpenCount') = 'U'
form.OpenCount = 1
form.entryfield1.value = 'Press ENTER to fire default pustbutton.'
case form.OpenCount = 1
form.OpenCount = 2
form.entryfield1.value = 'Now press TAB then ENTER.'
case form.OpenCount = 2
form.OpenCount = 3
form.entryfield1.value = 'Press ENTER to fire default pustbutton. Event
will not fire. Nor will TAB and ENTER.'
endcase
form.entryfield1.setFocus()
return
endclass
Ken Mayer [dBASE, Inc.]
2004-02-16 15:28:24 UTC
Permalink
Post by Garry Christensen
I don't know if this has been reported. I have a form that is instantiated
at the beginning of an app but only opened as I need it. It has an OK
button set as Default. I use it modal, opening it with readmodal().
I can press enter and the OK button fires, then closes the form. I can open
it again and repeat this as many times as I like. If I tab to the OK button
and press enter, the form closes as it should but on all subsequent uses,
the button refuses to respond to the Enter key, either as default or when it
has focus.
Run it the first time to instantiate it and press Enter to close it.
Run it again and tab to the button and press Enter.
Run it again and try to close it by pressing Enter. The button no longer
responds.
(watch for wordwrap)
I've entered QAID: 4694 for this.

Ken
---
Ken Mayer [dBASE, Inc.]
** Please respond ONLY in the newsgroups **

"Think OOP"

dBASE, Inc. website: http://www.dbase.com
Garry Christensen
2004-02-17 11:12:16 UTC
Permalink
Thanks Ken
Post by Ken Mayer [dBASE, Inc.]
I've entered QAID: 4694 for this.
Loading...