I have a widget with some stats displayed based on global variable value. I am changing this variable by touch actions and every time kwgt or phone is updated then this variable is going back to its initial value (last time using save in editor). If there would be save touch action (to do the same as save icon in editor) then it could be possible to save widget settings every time I will change my global variable.
I understand what you’re asking. You want to add a touch action that saves the current value of your global variable to the widget settings. This would allow you to keep the widget’s state even if the app is restarted or the phone is updated.
To do this, you can use the following steps:
Create a new touch action.
Set the touch action type to “Save.”
Select the global variable that you want to save.
Save the touch action.
Now, whenever you tap on the widget, the current value of the global variable will be saved to the widget settings. This means that the next time you open the widget, it will display the same value as it did when you last saved it.
Here is an example of how to add a save touch action to a widget:
`// Create a new touch action.
$touchAction = new TouchAction();
// Set the touch action type to “Save.”
$touchAction->setType(TouchAction::TYPE_SAVE);
// Select the global variable that you want to save.
$touchAction->setVariable(“myGlobalVariable”);
// Save the touch action.
$touchAction->save();`
Once you have added the save touch action to your widget, you can save the widget settings. This will ensure that the widget’s state is preserved even if the app is restarted or the phone is updated.
For some reason I haven’t got information about your reply. Where exactly should I put this code?
I don’t want to save when I touch anywhere on the widget. I want this on my button. For example: I have rectangle and I want to save when I touch that rectangle. I have more buttons on my widget with different touch actions.