[Closed] RC menu that close dialog differently but in one click
(
global Dialog01
global Dialog01
global MainMyRC
RcMenu MyTry
(
menuItem Cl_01 "Close"
-- function that close eachdialog separately when I pick this menu item
-- like when when in hlWorld01, I picked cl_01 it close hlWorld01 dialog only not hlWorld02
-- PS : when I pick those item, hlWorld02 also open
-- summary : all in one close button, but separately closing dialog
)
fn Dialog01 =
(
rollout hlWorld01 "Untitled" width:162 height:71
(
button btn3 "halo 01" pos:[8,10] width:144 height:32
on hlWorld01 rbuttondown mousehitpoint do (PopUpMenu MyTry)
)
createDialog hlWorld01
)
fn Dialog02 =
(
rollout hlWorld02 "Untitled" width:162 height:71
(
button btn4 "halo 02" pos:[8,10] width:144 height:32
on hlWorld02 rbuttondown mousehitpoint do (PopUpMenu MyTry)
)
createDialog hlWorld02
)
--====================================================================================
rollout MainMyRC "Untitled" width:150 height:59
(
button btn1 "Btn1" pos:[6,3] width:138 height:25
button btn2 "Btn 2" pos:[7,31] width:138 height:25
on btn1 pressed do
(
Dialog01()
)
on btn2 pressed do
(
Dialog02()
)
)
createDialog MainMyRC
)
Hi everyone, I need some suggestion or advice or help, I have RC menu that will pop out in different dialog (hlWorld01, hlWorld02), but I want it close dialog separately when I pick “Cl_01” in RC menu, basicly when I open hlWorld01&hlWorld02 at the same time , i right click hlWorld01 and pick CL_01, its only destroyDialog hlWorld01 , but not hlWorld02, same goes as reverse.
Do you have any idea how to do that ?
thanks
Try something like this (i also rearranged it a little bit so that you’re not creating new rollouts with each press of a button):
global MainMyRC
(
try (
destroyDialog MainMyRC
destroyDialog MainMyRC.hlWorld01
destroyDialog MainMyRC.hlWorld02
) catch()
rollout MainMyRC "Untitled" width:150 height:59
(
button btn1 "Btn1" pos:[6,3] width:138 height:25
button btn2 "Btn 2" pos:[7,31] width:138 height:25
-- private rollouts:
local hlWorld01, hlWorld02
local MyTry = rcMenu MyTry
(
local killRoll
fn init roll =
(
popUpMenu MyTry
killRoll = roll
)
menuItem Cl_01 "Close"
on Cl_01 picked do destroyDialog killRoll
)
rollout hlWorld01 "Untitled" width:162 height:71
(
button btn3 "halo 01" pos:[8,10] width:144 height:32
fn launch =
(
destroyDialog hlWorld01
createDialog hlWorld01
)
on hlWorld01 rbuttondown mousehitpoint do MyTry.init hlWorld01
)
rollout hlWorld02 "Untitled" width:162 height:71
(
button btn4 "halo 02" pos:[8,10] width:144 height:32
fn launch =
(
destroyDialog hlWorld02
createDialog hlWorld02
)
on hlWorld02 rbuttondown mousehitpoint do MyTry.init hlWorld02
)
on btn1 pressed do hlWorld01.launch()
on btn2 pressed do hlWorld02.launch()
)
createDialog MainMyRC
)
Thanks my friend , it work but it looks like its too still too hard for my little brain to understand your method…hehehe, i’ll work it out somehow.
btw thanks
as I understood only thing that you need is to know what dialog called the RC menu. After the knowing that you can do anything what you want with the dialog. Here is a sample how to use RCmenu’s local variables to pass extra data into RCmenu. In my sample I pass the rollout itself before popping the menu up:
rcmenu commonRC
(
local dialog =[color=Yellow] if dialog != undefined do dialog[/color] -- the trick helps to keep the variable from overriding
menuitem info ""
on info picked do if dialog != undefined do
(
format "dialog:%
" dialog
-- destroyDialog dialog
)
on commonRC open do if dialog != undefined do info.text = dialog.title
)
try(destroyDialog testRolA) catch()
try(destroyDialog testRolB) catch()
rollout testRolA "Rollout A" width:140
(
button info_bt "RC Menu" width:130
on info_bt rightclick do (commonRC.dialog = testRolA; popupmenu commonRC)
)
rollout testRolB "Rollout B" width:140
(
button info_bt "RC Menu" width:130
on info_bt rightclick do (commonRC.dialog = testRolB; popupmenu commonRC)
)
createDialog testRolA pos:[500,200]
createDialog testRolB pos:[650,200]
Thank you very much Denis, this is more understandable and simplified.
I like it. :love: