Toggle X-Ray Button Held Down
-
Hi guys,
I have written a very basic script that allows me to toggle X-ray rendering mode on and off from a custom made toolbar. However when the mode is active the icon does not remain 'pressed' as it does on the official 'Face Style' toolbar. The image below hopefully illustrates the effect I want. The code is also included.
Any help would be greatly appreciated. I have no idea how to approach this.
Thanks
Ross
toolbar = UI;;Toolbar.new "View" cmd = UI;;Command.new("X-Ray") { xray } cmd.large_icon = "CBG/togglexray_lg.png" cmd.small_icon = "CBG/togglexray_sm.png" cmd.tooltip = "Toggle X-Ray" toolbar = toolbar.add_item cmd toolbar.show # Toggle X-ray def xray if Sketchup.active_model.rendering_options["ModelTransparency"] == false Sketchup.active_model.rendering_options["ModelTransparency"] = true else Sketchup.active_model.rendering_options["ModelTransparency"] = false end end
-
I made an experimental feature like this recently - the Peek feature you see in this video: http://youtu.be/19BnGnR7bSs
What I did was create a tool that would detect which keyboard shortcut was assigned to the function that activates it. It then detect when the key(s) that triggered it is released where it then deactivates the tool.
The challenge is that you need to parse the list of shortcuts you get from
Sketchup.get_shortcuts
and translate it into what key codes and key flags. I just make a quick proof of concept and haven't mapped out things properly yet. Before I can post what I have as an example I need to extract the rest of the functions. -
Ross,
There is a possibility to do that
toolbar = UI;;Toolbar.new "View" cmd = UI;;Command.new("X-Ray") { xray } cmd.large_icon = "CBG/togglexray_lg.png" cmd.small_icon = "CBG/togglexray_sm.png" cmd.tooltip = "Toggle X-Ray" cmd.set_validation_proc { (Sketchup.active_model.rendering_options["ModelTransparency"]) ? MF_CHECKED ; MF_UNCHECKED } toolbar = toolbar.add_item cmd toolbar.show def xray() opts = Sketchup.active_model.rendering_options opts["ModelTransparency"] = !opts["ModelTransparency"] end
Fredo
-
Oh I completely misunderstood the question! Never mind me!
Advertisement