Update UI
Moderators: Víctor Paredes, Belgarath, slowtiger
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
Update UI
is it possible to add item to the toolbar, outside DoLayout event? on UpdateWidget?
- synthsin75
- Posts: 10264
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Update UI
You have to get it to reevaluate the DoLayout function.
I do this in my switch icons script by jumping to/from frame zero.
I do this in my switch icons script by jumping to/from frame zero.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
Re: Update UI
Are you sure changing frame to zero will trigger DoLayout?
Code: Select all
-- **************************************************
-- General information about this script
-- **************************************************
ScriptName = "Test_Script"
Test_Script = {}
function Test_Script:Name()
return 'Test Script'
end
function Test_Script:Version()
return '1.0'
end
function Test_Script:UILabel()
return 'Test Script'
end
function Test_Script:Creator()
return 'Test'
end
function Test_Script:Description()
return 'Test'
end
-- **************************************************
-- Is Relevant / Is Enabled
-- **************************************************
function Test_Script:IsRelevant(moho)
print('IsRelevant')
return true
end
function Test_Script:IsEnabled(moho)
print('IsEnabled')
return true
end
-- **************************************************
-- Events
-- **************************************************
function Test_Script:OnMouseDown(moho, mouseEvent)
print('OnMouseDown')
end
function Test_Script:UpdateWidgets(moho)
print('UpdateWidgets')
end
function Test_Script:HandleMessage(msg)
print('HandleMessage')
end
function Test_Script:DoLayout(moho, layout)
print('DoLayout')
local simple_dialog = LM.GUI.SimpleDialog('', {})
local popup_dialog = LM.GUI.PopupDialog('Test', true, 0)
popup_dialog:SetDialog(simple_dialog)
layout:AddChild(popup_dialog, LM.GUI.ALIGN_LEFT, 0)
end
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
Re: Update UI
And I don't know where is your script.
- synthsin75
- Posts: 10264
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Update UI
Here's the script: viewtopic.php?t=34078
At line 596, in the HandleMessage function, I do this:
At line 596, in the HandleMessage function, I do this:
Code: Select all
if (msg == self.UPDATE or msg == self.ALT_UPDATE or msg == self.DELETE) then
local frame = moho.frame
if (frame == 0) then
moho:SetCurFrame(1)
else
moho:SetCurFrame(0)
end
moho:SetCurFrame(frame)
end
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
Re: Update UI
I run your script and still changing layer selection will not update the UI.
However your solution works in updatewidgets for me. nice trick, thanks!
However your solution works in updatewidgets for me. nice trick, thanks!
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
Re: Update UI
I did some other test and realized your code dosn't work when we change from group to another group. So I mixed with the layer creation and deletion:
Code: Select all
local current_frame = moho.frame
moho:SetCurFrame(0)
local temp_layer = moho:CreateNewLayer(MOHO.LT_SWITCH, false)
moho:SetCurFrame(1)
moho:SetCurFrame(0)
moho:DeleteLayer(temp_layer)
moho:SetCurFrame(current_frame)
- synthsin75
- Posts: 10264
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Update UI
Yeah, I have a note in the code about group layer selections. I believe that problem was introduced in a later version of Moho, after I initially wrote the script.
I'll have to see about incorporating your layer creation hack.
Thanks.
I'll have to see about incorporating your layer creation hack.
Thanks.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
- MehdiZangenehBar
- Posts: 114
- Joined: Wed Feb 07, 2024 7:17 pm
- Contact:
Re: Update UI
Yea, and I created a boolean flag to prevent dependency loop and prevent UpdateWidget- DoLayout events call himself multiple times.
Another improvement would be to check the layer type and create different layer type to force the update.
Another improvement would be to check the layer type and create different layer type to force the update.