I have a simple textfield where I enter values, e.g "123"
I have a second textfield where the result of "inputvalue x 2" should be displayed, e.g. 246 (the result of 123x2)
On field A a have the event "OnEditChanged" which runs the calculation "input x 2".
Sounds great, but the problem is in detail, e.g. for "123"
- I press "1"
-> It calculates 1x2=2 and displays 2
-> It returns to field "A" and sets the cursor on the beginning of the field
- I press "2"
-> Instead of expected value "12" in field "A" I have now "21", because 2 was entered at the beginning of the field.
What to do to keep the normal order of the input - 123?
Happy new year to all!
What exactly does your OnEditChanged event handler do, and what does it return?
Hi Owen
here is the code:
(defun c:rbi_drawscale/bildskalierung/faktor#OnEditChanged (strNewValue /)
(setq faktor (abs (atof strNewValue))
soll (* faktor ist))
(dcl-Control-SetText rbi_drawscale/bildskalierung/faktor (rtos faktor 2 3))
(dcl-Control-SetText rbi_drawscale/bildskalierung/eff_distanz (rtos soll 2 3))
; Aushren-Button (de)aktivieren
(if (and soll ist faktor)
(dcl-Control-SetEnabled rbi_drawscale/bildskalierung/ausfuehren t)
(dcl-Control-SetEnabled rbi_drawscale/bildskalierung/ausfuehren nil)
)
)
https://www.screencast.com/t/ia7bZOaTJpEZ
It seems risky to change the notifying control's text from the OnEditChanged notification. If you must change the text, then you also need to manage the caret position. I think you should remove this line altogether:
(dcl-Control-SetText rbi_drawscale/bildskalierung/faktor (rtos faktor 2 3))
Thanks Owen - fixed.
(I don't know why I had the idea to use this line ...)