OnKillFocus running while starting "Options"?

Started by Peter2 · 2013-09-20 08:32 UTC · 7 replies · SMF topic #2028

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
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.
author=owenwengerd link=topic=2028.msg10004#msg10004 date=1379708973 wrote:
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 ..

author=owenwengerd link=topic=2028.msg10004#msg10004 date=1379708973 wrote:
....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?
author=Peter2 link=topic=2028.msg10005#msg10005 date=1379710018 wrote:
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.


author=Peter2 link=topic=2028.msg10005#msg10005 date=1379710018 wrote:
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 {2}.
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.
Hi Owen

author=owenwengerd link=topic=2028.msg10007#msg10007 date=1379711992 wrote:
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.

author=owenwengerd link=topic=2028.msg10007#msg10007 date=1379711992 wrote:
...a) See {2}....

Yes, thank you. That's the way ...
Still fighting with confusion ..

; 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".
Attachments
I can reproduce the problem. It looks like a bug. I will investigate and get it fixed for the next build.
Thank you.