OnKillFocus running while starting "Options"?

Started by Peter2, September 20, 2013, 01:32:50 AM

Previous topic - Next topic

Peter2

I'm creating a dialogue "new tab in Options" with text-fields to enter numbers (real).

The selected event should
- read the entered value (e.g. '3.14')
- write it to the registry and
- give a message: (princ "Value " value " was written to registry.")

Now I'm searching the best "event":
- "OnEditChanged" is not OK, because while typing "3.14" it runs 4 times
- "OnKillFocus" seemed to be OK, but this event also starts when I start the "Options" (without "oninitialize")

Questions:
a) Is is right that OnKillFocus also starts when the "AutoCAD-Options" are called?
b) Is there another event to handle it immediately - or is is better handle it in the entire dialogue with "OptionOK" and "Show"?

Thanks and regards
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

It does seem strange that OnKillFocus fires before OnInitialize, but there is no guarantee about that. In your case, I think you should be using OnOptionsApply.
Owen Wengerd (Outside The Box) / ManuSoft

Peter2

Quote from: owenwengerd on September 20, 2013, 01:29:33 PM
It does seem strange that OnKillFocus fires before OnInitialize, ....
Yes. For testing the first lini in OnInitialize is an Alert, and while the alert is display I can see in the command-line that OnKillFocus is already done ..

Quote from: owenwengerd on September 20, 2013, 01:29:33 PM
....In your case, I think you should be using OnOptionsApply.
This is what I tried, but ..
a) the "Apply" Button is always disabled (did I miss a command to enable it?)
b) what will happen when the user changes the tabs without "Apply"? Do I need also a "Show" Event?
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

Quote from: Peter2 on September 20, 2013, 01:46:58 PM
For testing the first lini in OnInitialize is an Alert, and while the alert is display I can see in the command-line that OnKillFocus is already done ..

The alert dialog would take input focus from the options tab, so OnKillFocus would be expected in that case.


Quote from: Peter2 on September 20, 2013, 01:46:58 PM
a) the "Apply" Button is always disabled (did I miss a command to enable it?)
b) what will happen when the user changes the tabs without "Apply"? Do I need also a "Show" Event?

a) See SetApplyEnabled.
b) The logic depends on what your goal is. Is it a problem if the user changes tabs without applying the changes? If so, then you must use OnKillFocus.
Owen Wengerd (Outside The Box) / ManuSoft

Peter2

Hi Owen

Quote from: owenwengerd on September 20, 2013, 02:19:52 PM
The alert dialog would take input focus from the options tab, so OnKillFocus would be expected in that case....
I reduced all features step by step ..
a) use "princ" instead of "alert"
b) removed "princ"
c) removed the "c:..oninitialize" code from lisp
d) removed the "onintialize" event from ODCL

Result: "OnKillFocus" was fired all the time.

Quote from: owenwengerd on September 20, 2013, 02:19:52 PM
...a) See SetApplyEnabled....
Yes, thank you. That's the way ...
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

Peter2

Still fighting with confusion ..

Code (autolisp) Select
; mache bei OK das gleiche wie bei Apply
(defun c:Verdrahtung_opt_verdrahtung_OnOK (/)
    (c:Verdrahtung_opt_verdrahtung_OnApply)
)
;;;;;;;######################################################################
(defun c:Verdrahtung_opt_verdrahtung_OnApply (/)
  (dcl_MessageBox "Hier sollte etwas Sinnvolles passieren: An dieser Stelle können Sie nun den Quellcode zur Ereignisfunktion hinzufügen\r\nc:Verdrahtung_opt_verdrahtung_OnApply" "Ereignisfunktion")
  (dcl_Form_SetApplyEnabled Verdrahtung_opt_verdrahtung nil)
)


In my "options" the Apply-Button is enabled, but a click on it does nothing.
Click on "OK" calls correctly the "apply-function".
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

I can reproduce the problem. It looks like a bug. I will investigate and get it fixed for the next build.
Owen Wengerd (Outside The Box) / ManuSoft

Peter2

Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10