Form closes on Enter

Started by kenkrupa, June 16, 2011, 05:34:01 PM

Previous topic - Next topic

kenkrupa

My form has a few text boxes set up to advance like a tab on Enter. That works fine. But after the last it advances to the first of four text buttons, and visibly shows it having focus. But pressing Enter does not fire it - it just exits the form. Same goes for any of these buttons. The onOK event for the form does not help, as I can't find any way to know which button had focus at the time. Am I missing some way to deal with this? (v 6.0.2.3, R2012, Win7-64)

owenwengerd

Have you tried (dcl_GetFocus)? That should work during OnOK.
Owen Wengerd (Outside The Box) / ManuSoft

Fred Tomke

Hi,

Quote from: kenkrupa on June 16, 2011, 05:34:01 PM
My form has a few text boxes set up to advance like a tab on Enter. That works fine. But after the last it advances to the first of four text buttons, and visibly shows it having focus. But pressing Enter does not fire it - it just exits the form. Same goes for any of these buttons. The onOK event for the form does not help, as I can't find any way to know which button had focus at the time. Am I missing some way to deal with this? (v 6.0.2.3, R2012, Win7-64)

I'm not sure, if you've already tried this but I always activate OnCancelClose whenever a textbox is on the form.
OnCancelClose will be executed when you press enter.
If you need a sample, have a look here.

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

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

kenkrupa

Thank you both - enormously helpful! I used a combination of both to get exactly what I wanted. With the OnOk I can know which button was focused on Enter. That left me still with an undesirable exit on Enter from a list box. The OnCancelClose, with some help from Fred's textinput.LSP, provided the answer. Thank you much!

(defun c:Dialog_OnOk (/ control)
  (setq control (caddr (dcl_GetFocus)))
  (alert (strcat "Dialog_OnOk: " control))
)
(defun c:Dialog_OnCancelClose (Reason)
  (and (/= reason 1) (= (caddr (dcl_GetFocus)) "lstShapes"))
)