button pressed enter key and "OnCancelClose" problem

Started by khann, August 24, 2010, 02:30:15 AM

Previous topic - Next topic

khann

Hi, there.

I wonder why the button does not have "Return pressed " Event.

A form have some buttons and other controls with tab stop true property.

When I press enter key to step one control to another , on the button control pressed enter key,
it goes to form's "OnCancelClose" Event.

The "OnCancelClose" Event has just reason arg, normaly returns "0" value and the form does not close.

But I want some special button pressed enter key to close form.

Hope someone show me the way.

Thanks.

Fred Tomke

Hi khann

A button doesn't need a OnReturnPressed event. If the button has focus, the same event will be called as you would left click the button. It is new to me that pressing Enter on a text button would call OnCancelClose. But if so, I can imagine to create a cond-condition within CancelClose to get the information which control had focus when pressing Enter (using (dcl_GetFocus)).

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

khann

Thanks, Fred.
Nice to meet you.

I never thought and never heard the button pressed enter key calls the OnClicked Event.

In my test, textButton pressed enter key, it calls the form's "OnCancelClose"
and returns "Reason" arg value 0, does not close the form.

But delete "OnCancelClose" from the form, textButton pressed enter key just closes the form
and does not calls the "OnClicked" Event.

The modeless form's "Keep Focus" value is false.

What's wrong with this?

I'm testing OpenDCL Runtime [6.0.0.27]. with AcadMap 2005, XP SP2.

Thanks.

Fred Tomke

Hm, interesting, it works for me - but I'm using modal forms. Can you upload a simple sample for me for testing?

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

khann

All right.
Here is a sample.
Thanks again.

Fred Tomke

Hi, khann, there must be a difference between Focus and Focus. Try to press SpaceBar instead of Enter.

a) If you press enter in the text box, Return should behave as Tab (as you've set in OpenDCL Studio). Then the focus moves to the text button (the focus rectangle can be seen there). If you press Enter, Button_OnClicked won't be called. But if you press SpaceBar Button_OnClicked will be called ?!

b) If you click the textbutton and move the mouse outside the text button while pressing the left mouse button, OnClicked won't be called (because the internal OnMouseUp events is called outside the textbutton). The focus rectangle is still on the textbutton. If you hit Enter key now, OnClicked-event will be called.

The thing is: the textbutton has no OnReturnPressed event, so you cannot catch it. But the thing you can do is the following:


  • Set the property ReturnAsTab to False.
  • Activate OnCancelClose event.
  • Within CancelClose event check if IsESCWasPressed is zero.
  • If IsESCWasPressed is zero and the text value is valid call (c:project_form_TextButton_OnClicked) manually.
  • If more than one cases exist then catch the currently focussed control in a cond-condition.

Greetings
Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

khann

Thanks.
So kind of you, Fred. :)

I'll make it as you said.