Good afternoon group… how can I recall the click of a button without physically pressing it?
Something like that
Call MyButton.pressed ?
I test my button name…PulsanteOKAggiorna.press but not work.
Good afternoon group… how can I recall the click of a button without physically pressing it?
Something like that
Call MyButton.pressed ?
I test my button name…PulsanteOKAggiorna.press but not work.
You may simply move the code from the pressed event into a method and call that method from the pressed event instead. This way, you can also call the method from elsewhere.
edit: fixed typo.
Yes, of course, I understood that. It’s just that I wanted to lighten the code, avoiding repeating the instructions having already written them somewhere else, in this case in the PRESSED event of the ButtonOkUpdate button
The idea is not to copy the code, but to move it. It is only in one place. It is also a good idea to separate the logic from the UI. This way, the code is easier to adapt to a change in UI.
By putting it in a Method?
https://documentation.xojo.com/api/user_interface/desktop/desktopbutton.html#desktopbutton-press
And Louis is right: add a Method, Move (Copy/Paste) the code from the button to the Method and call that method from where you need (the Button, elsewhere).
yes. the logic is no longer directly tied to the UI. Think for example abot creating a web version of a desktop app. you mostly change the ui, without the need to revisit the logic. It is obviously not so simple, but the example remains valid.
Call PushButton.Press
Causes the button to be visually pressed, as well as triggering the Pressed event.
Call Press when the user has pressed the keyboard equivalent for the button to give the appropriate visual feedback.
This example presses Button1. It is called from another control.
Button1.Press
Ok Louis, I solved
Thanks.