dcl closes on hitting enter...

Started by Hypersonic · 2007-12-31 18:55 UTC · 10 replies · SMF topic #129

When entering data into a text box, and if you hit enter, it closes the dialog.
Is there any way to stop this , and maybe make hit enter step to the next box?

Thanks!
Try setting the text box 'ReturnAsTab' property to 'True'.
Thanks Owen! ;D
Thanks for the tip on trapping the "Enter" key being pressed, however I cannot seem to get the "OnReturnPressed" event to fire for a textbox control.  I have added the following lines to my LSP code for a text box that is to receive an address:

(defun c:Addr_frmAddr_txtAddrNum_OnReturnPressed ()
  (dcl_Control_SetFocus Addr_frmAddr_cmdFind)
  (princ "\nPressed while in the txtAddrNum TEXT box...")
  (find_records)
);

After I type in an address, I would like to hit the "Enter" key and fire off the "find_records" function.  The function already behaves properly as I have already associated it with the "cmdFind_OnClicked" button. 


(defun c:Addr_frmAddr_cmdFind_OnClicked (/)
  (find_records)
);end CMDFIND_ONCLICKED



The "ReturnAsTab" property has been set to "True," as suggested.  This is confusing.  I am running version 4.1.0.10, AutoCAD Map 2004, WinXP, SP2
author=nwgeo link=topic=129.msg614#msg614 date=1201112802 wrote:
Thanks for the tip on trapping the "Enter" key being pressed, however I cannot seem to get the "OnReturnPressed" event to fire for a textbox control.


If you need to respond when the user presses , you should set ReturnAsTab back to False and use a different approach.  Try responding to the key press by handling the OnOK event, then cancel the dialog closing by responding to the OnCancelClose event.  If OnOK doesn't work, you can try the OnKeyDOwn event of the edit box. :)
Well, the OnOK event didn't quite do what I wanted.  Also the OnKeyDown for the text box fired everytime I hit a key [like it's supposed to I guess], but this makes it impossible to enter a five digit address number as the event code gets fired five times :(

solution - I set the ReturnAsTab property back to True and changed the tab order so that the "Find Address" button follows directly after the address text box.  The user can hit the Return key twice, it's still faster than picking up the mouse just to click a button...

Still, I'm curious why I can't get the "ReturnPressed" event to fire in my application.  Oh well, Rev 2.0 I guess.

Thank you for responding to my post and giving me a few items to try.
author=nwgeo link=topic=129.msg616#msg616 date=1201125727 wrote:
the OnKeyDown for the text box fired everytime I hit a key [like it's supposed to I guess], but this makes it impossible to enter a five digit address number as the event code gets fired five times :(


Would this method work if your event handler ignored all the keys except the key?
Hello,

I've got the same problem, but i still working with 4.1.2.1 odcl tools.

If i begin a new dailog box, whith an empty form, pressing key make dcl close.

There is no way to keep form alive ....

I find something for easy form .... I show again the form whith OnOk event ...

(defun c:GPE:PROJET_OnOK ( /)
    (dcl_Form_Show "boite.projet" "GPE:PROJET")
)


But still working with simple form .
Hello,

have a look at OnCancelClose.
If you need an example, tell me.

Fred
author=Fred Tomke link=topic=129.msg1534#msg1534 date=1212495436 wrote:
Hello,

have a look at OnCancelClose.
If you need an example, tell me.

Fred


Hello Fred,

Yes, because,i tried many times with all options existing in a default frame, but key make it close !

Is there any option, like "isdefault" option in dcl, to tell than i want to put a button as default ????

I will be very please, if you can show me how to not close a frame with key pressed, with a blank frame for example ...  :P

Thanks ....  ;)
Hello,

please try the attached project. Unfortunately, I've never seen that OnOk was called. Mostly I use it with Textbox.

Fred
Attachments