I need to have two edit-texts so that when I change the value in one, the other is updated. In particular, if one edit-text is A and the other is B, then when A changes, B needs to be A*F1/F2 where F1 and F2 are field values and when B changes A needs to be set to B*F2/F1.
A bit hacky but maybe itād be possible to use a placeholder to show the calculated value, i.e:
letās call āedit-text for field Aā edit-A and equivalent for edit-B
then use an action delete such that entering into edit-A deletes content in B and vice versa
and let the placeholder value for each show the calculated value
You can style a placeholder value so it doesnāt look faded.
Actually, this is probably not āhackyā. This is probably how to do it.
The ātrickā is to use the $eventcatcher widget with a $change handler, so that you can enter a value in the A or B field, and only trigger an update of the other field when the focus leaves the input field and the field value has been changed.
Friendly words of advice: learn to āseparate concernsā. Co-mingling producers (macros, procedures, et al) amongst and within your code would be like dragging around the manufacturing facility (along with all their suppliers) for the car youāre driving.
Needless to say, in both cases, itās not possible.
Actually, when the value in the edit text changes, the field is updated immediately, so canāt I just have a widget that constantly updates the other field (without catching events)? I guess action-setfield is not good since it sets the field only when triggered as an action.
Well, in my case there are several edit texts and I want to change another field according to the fields they changed. Essentially I think iām looking for a spreadsheet like behavior. If A3 has =A1+A2 then whenever A1 or A2 change, A3 changes. Seems like wrapping everything in eventcatchers or using inputactions is too verbose.
Like in speadsheets rather than update the value in the formula, it is better to store the values separately, only once and use a reference to the ācellā,