Toolbar Icon checked_unchecked
-
I have been trying to create toolbars auto closed when a tool item selected,
If Toolbar is checked "off" at my array holds toolbar names.
First item of a toolbar is used to mark this toolbar off/on at array.
Thou.. My code works;..
I have seen that validation process cause endless loop at my code and other validation procs used.
Any better simple and safe code pleases?#localized instance vars. toolbar_name = @cmdstbname toolbar_look = @cmdsubtoolbar toolbar_check = @checkstbar check_no = @checkindex cmd = UI;;Command.new("Fixpanel_"+toolbar_name) { if @txtoolbar_name_array[check_no][2] == "off" @txtoolbar_name_array[check_no][2]= "on" Sketchup.status_text = " (#{toolbar_name}) Panel Pinned no auto- close when a tool selected." else @txtoolbar_name_array[check_no][2]= "off" Sketchup.status_text = "(#{toolbar_name}) Panel tempered to auto- close." end } cmd.small_icon = "../images/ruby_favorite_SM.png" cmd.large_icon = "../images/ruby_favorite_LG.png" cmd.tooltip = " Pin (#{toolbar_name}) Panel" cmd.status_bar_text = " Pin (#{toolbar_name}) Panel" cmd.menu_text = " Pin (#{toolbar_name}) Panel" cmd.set_validation_proc { p {check_no} if @txtoolbar_name_array[check_no][2]== "on" MF_CHECKED else MF_UNCHECKED end } @cmd = cmd # add cmd.item to toolbar ##### or #### def check_validation_proc(check_no) p {check_no} if @txtoolbar_name_array[check_no][2]== "on" return MF_CHECKED else return MF_UNCHECKED end end cmd.set_validation_proc { check_validation_proc(check_no) }
Beware: Jim.Foltz ToolBar 2010 does same loop. if you inject - p "this is bug." - in 'toggleperspective.rb' you'll see this.
it repeats till toolbar closed. -
Validation procs are evaluated extremly frequently - ensure they do as little as possible.
-
Do not use Custom Toolbars as an example for creating toolbars - it uses unconventional techniques that won't make sense outside of Custom Toolbars (i.e.
@cmd = cmd
)In your example, you have defined the validation proc twice. Also, calling "return" from a proc doesn't make sense - when the proc exits, the value MF_CHECKED is returned implicitly.
-
@jim said:
In your example, you have defined the validation proc twice. Also, calling "return" from a proc doesn't make sense - when the proc exits, the value MF_CHECKED is returned implicitly.
Thx. jim. i did not use twice. but, sampled it here that your code also makes infinite loop as i have install at GSU8m2.
I need help to over come this. But Thom say do not use it. no solution for this?I have been testing my "Clean DeskTOP.rb" plugin to simulate menus on toolbar build on Jim Foltz Toolbar plugin. very close to post here. but i have no idea about copyrights that i could develop on his plugin. May i?
sample. Clean DeskTOP.
-
OK, I viewed this topic (per request,) and I do not have anything more to add to what Thomas and Jim have said.
-
@dan rathbun said:
OK, I viewed this topic (per request,) and I do not have anything more to add to what Thomas and Jim have said.
Ok. I am closing this thread with following conclusion.
As far as i understand after examining all codes on toolbar and menu validation,"MF_" validation cause implicite loop at menu and toolbar handling to lower SU GUI-process.
Since, most of SU-Toolbars use that validation procs they cost process time while they are open at your desktop.
it might be why SU-menus autoclose. Since, we can't handle SU custom toolbars, we dont see how they are flouding on screen.
I wonder why they use "MF_" validation at Toolbars, if it is Menu associated.
That could be a reason for me to develop "Clean DESKTOP" plugin to organize Toolbars as "PS" utilizes. -
I do not think there is an infinite loop - the repeating output is because the validation proc is being called by SketchUp very frequently.
@gultekinmg said:
i have no idea about copyrights that i could develop on his plugin. May i?
Sure. I like the idea of disappearing toolbars.
-
@jim said:
I do not think there is an infinite loop - the repeating output is because the validation proc is being called by SketchUp very frequently.
frequently as much they MF_check, MF_unchek toolbar items. As long as CustomToolbars are open i guess they are repeading output.
@jim said:
Sure. I like the idea of disappearing toolbars.
Mercy, Jim. I'll post free for noel. I hope you customize it as you like it. All yours.
I'll drop item.cmd validation from code. sry that.
Advertisement