Default button fires 2 events 
Author Message
 Default button fires 2 events

I am running into a problem with buttons when the Cancel or Default
properties are set to True. This problem occurs when an object that is not
part of the eVB runtime (such as a grid control) is placed on the form. If
this occurs, two click events are fired when the Escape/Enter key is
pressed.

To demonstrate this problem, add a text box (Text1) and a command button
(command1) to an eVB form. Then add the following code:

Private Sub Command1_Click()

   Text1.Text = Text1.Text & "Clicked! "

End Sub

Private Sub Form_Load()

   Command1.Default = True

   Command1.Cancel = True

End Sub

Running this code in the emulator with your keyboard, or a device with
buttons, works as expected: pressing the Escape/Enter key fires 1 click
event and updates the text box appropriately. Now, to duplicate the problem,
add an ActiveX control such as MSFlexGrid to the form. Pressing the
Escape/Enter key will now fire 2 click events.

Has anyone seen this problem or know of a fix/workaround? Our application
dynamically assigns cancel and default buttons. Our users should be able to
use both the touch screen and/or the buttons. Any help in solving this
problem is appreciated.

Thanks,

Mike Calahan



Sat, 06 Dec 2003 04:55:17 GMT  
 Default button fires 2 events
Hi Mike:

The quick fix is to set a flag variable the first time the
button is clicked and in the Click() event don't do
anything if the flag is true.
(You also have to reset this flag after)

Vincent Collura
(Inventor/Engineer)

http://www.CeBeans.com
Did you get your beans Today?


Quote:
> I am running into a problem with buttons when the Cancel or Default
> properties are set to True. This problem occurs when an object that is not
> part of the eVB runtime (such as a grid control) is placed on the form. If
> this occurs, two click events are fired when the Escape/Enter key is
> pressed.

> To demonstrate this problem, add a text box (Text1) and a command button
> (command1) to an eVB form. Then add the following code:

> Private Sub Command1_Click()

>    Text1.Text = Text1.Text & "Clicked! "

> End Sub

> Private Sub Form_Load()

>    Command1.Default = True

>    Command1.Cancel = True

> End Sub

> Running this code in the emulator with your keyboard, or a device with
> buttons, works as expected: pressing the Escape/Enter key fires 1 click
> event and updates the text box appropriately. Now, to duplicate the
problem,
> add an ActiveX control such as MSFlexGrid to the form. Pressing the
> Escape/Enter key will now fire 2 click events.

> Has anyone seen this problem or know of a fix/workaround? Our application
> dynamically assigns cancel and default buttons. Our users should be able
to
> use both the touch screen and/or the buttons. Any help in solving this
> problem is appreciated.

> Thanks,

> Mike Calahan



Sun, 07 Dec 2003 02:04:56 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Firing proper events with default/hotkey button

2. Button events won't fire when editing a cell

3. Button Click Event Not Firing !

4. ESC still fires Validating events but clicking the Cancel button does not

5. IE4.0pp2 - Radio buttons do not fire events?

6. OnClick event only fires on one of two radio buttons

7. Clearing radio buttons without firing click event

8. Control Event Problem (Post Event after an event is fired)

9. click event not firing if lost_focus is firing first

10. ItemChange event firing off after ItemAdd event

11. Make your class fire an Event ( custom class event, RaiseEvent )

12. ATL COM Component firing events into VBScript event sink

 

 
Powered by phpBB® Forum Software