Replies: 1 comment
-
I can see how glgui:uiform-arg is useful to have as the standard thing to call for retrieving arguments as it allows any parameter to be dynamic on page load - that is when the LNHealth page is loaded depending on some logic, you can change an aspect of a widget. I think this particular argument for this particular widget should be an exception though as we expect it to always be a procedure and it does make sense to only run it at call back time - when someone has clicked on it. If someone wants to dynamically provide a procedure they could still setup the procedure in their app code and pass the result as the action. Alternatively, if people don't want this changed, just make a procedure that returns your procedure and pass that in as the action argument. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I'd like to propose a small change to the uiform module.
To give some context, I came across this when adding a "list" widget. The list widget shows a number of entries, from which the user can choose one.
We can make selections trigger an action with the 'action' tag.
However, I found that the action triggers before the selection is set. This does not seem right, since one would usually want to use the value that was selected.
For example, if I set the action to print the value, then click both buttons:
Click first button -> "None" (default)
Click second button -> "Option1"
The relevant code is here:
lambdanative/modules/uiform/uiform.scm
Lines 1364 to 1379 in 4334b9d
What happens is that the action is performed on line 1372. The function
glgui:uiform-arg
actually evaluates functions while retrieving them.THEN, the value of the widget is set. By line 1377, when it looks like we are calling the action, we are actually returning the result that was already evaluated.
It would be easy to reorder this so that the action gets called after setting the value, without affecting anything else.
I've looked through the rest of uiform, and a similar pattern is used elsewhere (like in button), but since there is no value-setting, it works as expected.
Happy to hear any thoughts! Thanks for your time in reading this.
Beta Was this translation helpful? Give feedback.
All reactions