Hello Dear All,
I tried to create to do list with that code for my daily routine (like check list):
--myname and date
macroScript TodoList
category:"DragAndDrop"
toolTip:""
Icon:#("todolist",1)
(
rollout unnamedRollout "TodoList" width:248 height:320
(
checkbox 'chk4' "" pos:[24,40] width:21 height:30 align:#left
editText 'edt4' "" pos:[43,43] width:169 height:25 align:#left
checkbox 'chk5' "" pos:[24,80] width:21 height:30 align:#left
editText 'edt5' "" pos:[43,83] width:169 height:25 align:#left
checkbox 'chk6' "" pos:[24,120] width:21 height:30 align:#left
editText 'edt6' "" pos:[43,123] width:169 height:25 align:#left
checkbox 'chk7' "" pos:[24,160] width:21 height:30 align:#left
editText 'edt7' "" pos:[43,163] width:169 height:25 align:#left
checkbox 'chk8' "" pos:[24,200] width:21 height:30 align:#left
editText 'edt8' "" pos:[43,203] width:169 height:25 align:#left
checkbox 'chk9' "" pos:[24,240] width:21 height:30 align:#left
editText 'edt9' "" pos:[43,243] width:169 height:25 align:#left
)
)
CreateDialog unnamedRollout
But getting that error!
And I'm really curious about how to save that for next restart! Don't know how to create string variable for edit text and state of check boxes regarding how to save them and load them for next restart? I can't launch the code as a button as well (click won't respond) only run script respond!
Any idea how to fix it?
Best Regards
Solved! Go to Solution.
Solved by a2d4f3s1. Go to Solution.
Solved by denisT.MaxDoctor. Go to Solution.
Your rollout is out of scope. The most usual way is to create an "on execute" handler in the "macroscript" and call createdialog from there. There you can also restore the dialog position.
Hello again,
I figure it out floater and rollout finally, thanks to Aaron Dabelow
Here working sample:
--myname and date
macroScript TodoList
category:"DragAndDrop"
toolTip:""
Icon:#("todolist",1)
(
try (closeRolloutFloater RolloutFloaterTemplate) catch()
rollout RolloutTemplate "TodoList"
(
checkbox 'chk4' "" pos:[24,20] width:21 height:30 align:#left
editText 'edt4' "" pos:[43,23] width:169 height:25 align:#left
checkbox 'chk5' "" pos:[24,60] width:21 height:30 align:#left
editText 'edt5' "" pos:[43,63] width:169 height:25 align:#left
checkbox 'chk6' "" pos:[24,100] width:21 height:30 align:#left
editText 'edt6' "" pos:[43,103] width:169 height:25 align:#left
checkbox 'chk7' "" pos:[24,140] width:21 height:30 align:#left
editText 'edt7' "" pos:[43,143] width:169 height:25 align:#left
checkbox 'chk8' "" pos:[24,180] width:21 height:30 align:#left
editText 'edt8' "" pos:[43,183] width:169 height:25 align:#left
checkbox 'chk9' "" pos:[24,220] width:21 height:30 align:#left
editText 'edt9' "" pos:[43,223] width:169 height:25 align:#left
)
RolloutFloaterTemplate = newrolloutfloater "TodoList" 248 320
addrollout RolloutTemplate RolloutFloaterTemplate
)
Still trying to find how to save checkbox state and edit text string value!
Cheers
So far testing some different ways:
This is the core section:
Copy that code multiple times to create all other UI components:
Copying the code multiple times inefficient, so I tried to iterate with loop logic but won't work!
Any idea why it won't work? @istan @a2d4f3s1
try closeRolloutFloater ::RolloutFloaterTemplate catch() --if already exist then destroy and open new one
(
rollout RolloutTemplate "TodoList"
(
checkbox 'chk1' "" pos:[14,15] width:21 height:30 align:#left
editText 'edt1' "task " pos:[43,23] width:169 height:25 align:#left
)
for i = 1 to 5 do --repeat five times, for each iteration do:
(
chk1_copy = copy checkbox
chk1_copy.pos = [0, i*5] --place it i*5 units along y
edt1_copy = copy editText
edt1_copy.pos = [0, i*5] --place it i*5 units along y
)
RolloutFloaterTemplate = newrolloutfloater "TodoList" 248 320
addrollout RolloutTemplate RolloutFloaterTemplate
)
There is RolloutCreator mechanism in MXS... learn it using the MXS Help, and my example:
macroScript ToDoList
category: "Examples"
buttonText:"TODO LIST"
toolTip:"What should I do?"
autoUndoEnabled:off
silentErrors:off
(
local d
local rcg
local dialog_width = 400
local number_tasks = 10
fn makeDotoList count:1 =
(
rollout_name = "RolloutToDo"
rcg = rolloutCreator rollout_name "What should I do?" width:dialog_width
rcg.begin()
rcg.addText "local opened = if opened != undefined do opened"
rcg.addControl #label #emp00_lb ""
local cb_base_name = "completion_cb_"
local tb_base_name = "description_tb_"
local cb_names = #()
local tb_names = #()
for k=1 to count do
(
id = formattedprint k format:"03d"
cb_name = cb_base_name + id
cb_text = "Task " + k as string
rcg.addControl #checkbox cb_name cb_text \
paramstr:("text:\"" + cb_text + "\" align:#left offset:[-4,0] across:2")
append cb_names cb_name
tb_name = tb_base_name + id
rcg.addControl #edittext tb_name "" \
paramstr:("width:" + (dialog_width - 80) as string + " height:1 align:#right offset:[4,-1]")
append tb_names tb_name
)
with printAllElements on
(
code = " local cb_controls = " + cb_names as string + "\n"
rcg.addText code
code = " local tb_controls = " + tb_names as string + "\n"
rcg.addText code
)
code = " fn findControl name =\n"
code += " (\n"
code += " for c in " + rollout_name + ".controls where c.name == name do exit with c\n"
code += " )\n"
code += " fn completeTask id: =\n"
code += " (\n"
code += " format \"complete(%) ... state:%\\n\" id (findControl cb_controls[id]).state\n"
code += " )\n"
code += " fn describeTask id: =\n"
code += " (\n"
code += " format \"describe(%) ... text:%\\n\" id (findControl tb_controls[id]).text\n"
code += " )\n"
rcg.addText code
for k=1 to count do
(
rcg.addHandler cb_names[k] "changed state" codeStr:("completeTask id:" + k as string)
rcg.addHandler tb_names[k] "entered text" codeStr:("describeTask id:" + k as string)
)
rcg.addControl #label #emp01_lb "" height:4
code = " (\n"
code += " opened = off\n"
code += " updateToolbarButtons()\n"
code += " )\n"
rcg.addHandler rollout_name #close codeStr:code
code = " (\n"
code += " opened = on\n"
code += " updateToolbarButtons()\n"
code += " )\n"
rcg.addHandler rollout_name #open codeStr:code
rcg.end()
rcg.def
)
global RolloutToDo =
(
if iskindof (_d = try(globalvars.get #RolloutToDo) catch()) RolloutClass do try(destroydialog _d) catch()
makeDotoList count:number_tasks
)
fn destroy =
(
try(destroydialog d) catch()
)
fn create =
(
createdialog d style:#(#style_titlebar, #style_border, #style_sysmenu, #style_minimizebox)
)
fn enabled =
(
iskindof (d = try(globalvars.get #RolloutToDo) catch()) RolloutClass
)
on isChecked do enabled() and (d.opened == true)
on execute do if enabled() do
(
if (d.opened != true) then create() else destroy()
updateToolbarButtons()
)
)
The method using MXS by denisT.MaxDoctor is excellent.
I don't recommend it, but I'll show you other ways to do this.
Rollouts = #()
RolloutNum = 10 -- Number of iterations
fn fn_addRollout num =
(
executeString = ""
numTxt = num as string
executeString += "rollout 'RolloutTemplate"+numTxt+"' \"TodoList"+numTxt+"\"\n"
executeString += "(\n"
executeString += "\t"+"checkbox 'chk1' \"\" pos:[14,15] width:21 height:30 align:#left \n"
executeString += "\t"+"editText 'edt1' \"task \" pos:[43,23] width:169 height:25 align:#left \n"
executeString += ")\n"
executeString
)
try closeRolloutFloater ::RolloutFloaterTemplate catch() --if already exist then destroy and open new one
(
for i = 1 to RolloutNum do --repeat five times, for each iteration do:
(
RolloutString = fn_addRollout i
Rollouts[i] = execute RolloutString
)
RolloutFloaterTemplate = newrolloutfloater "TodoList" 248 320
for i = 1 to RolloutNum do
(
addrollout Rollouts[i] RolloutFloaterTemplate
)
)
Thank you very much guys, there is a lot of information, always keep learning..
@denisT.MaxDoctor @a2d4f3s1
Best Regards
Can't find what you're looking for? Ask the community or share your knowledge.