OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: khann on August 24, 2010, 02:30:15 AM

Title: button pressed enter key and "OnCancelClose" problem
Post by: khann on August 24, 2010, 02:30:15 AM
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.
Title: Re: button pressed enter key and "OnCancelClose" problem
Post by: Fred Tomke on August 24, 2010, 10:52:31 AM
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
Title: Re: button pressed enter key and "OnCancelClose" problem
Post by: khann on August 24, 2010, 05:39:43 PM
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.
Title: Re: button pressed enter key and "OnCancelClose" problem
Post by: Fred Tomke on August 25, 2010, 03:53:22 PM
Hm, interesting, it works for me - but I'm using modal forms. Can you upload a simple sample for me for testing?

Fred
Title: Re: button pressed enter key and "OnCancelClose" problem
Post by: khann on August 25, 2010, 05:26:50 PM
All right.
Here is a sample.
Thanks again.
Title: Re: button pressed enter key and "OnCancelClose" problem
Post by: Fred Tomke on August 26, 2010, 04:28:04 AM
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:


Greetings
Fred
Title: Re: button pressed enter key and "OnCancelClose" problem
Post by: khann on August 26, 2010, 05:53:42 PM
Thanks.
So kind of you, Fred. :)

I'll make it as you said.