PDA

View Full Version : Callbacks and macroscripts with buttons?


3rd Dimentia
03-25-2008, 06:57 AM
Hi, I've only just started playing with callbacks. I have a basic understanding of them where I can get this to work

callbacks.removescripts id:#printTest
fn PrintSomething =
(
print " HEY it's working"
)
callbacks.addscript #byCategoryDisplayFilterChanged "PrintSomething()" id:#printTest

I have a macroscript that I use to show and change the hide by category without having to go to the display command panel which is this:

macroScript HideByCategoryGeom
buttonText:"G"
category:"CgRay"
toolTip:"Hide By Category Geometry"
(
on isChecked do
( hideByCategory.geometry
)

on execute do (
hideByCategory.geometry = not hideByCategory.geometry
)
)


The issue I have, is that when I use this it works fine and the toolbar button changes if you change the hide by category with the keyboard shortcut. And it works fine by using the macroscript button. But when you change the hide by category option in the display command panel, the toolbar macroscript button doesn't change. I'm figuring I need to use a callback but am unsure of how to go about incorporating a callback into that macro. Can anyone help?


Cheers,

Cg.

Jon-Huhn
03-25-2008, 12:21 PM
Try putting this in your callback script:


updateToolbarButtons()

3rd Dimentia
03-25-2008, 01:21 PM
Hi Jon, thanks for the reply. I'm not sure what you mean though. I don't actually have a callback working with the macroscript. I need to know how to add a callback somehow to the macroscript so that when the checkbox in the display command panel is updated, a callback (that I don't know how to implement yet) will update the buttons on the toolbar accordingly. Not sure if I'm being clear with my explaination.

Cheers,
Cg.

3rd Dimentia
03-25-2008, 01:39 PM
Ah, I think I understand what you mean... Like have a seperate function that's executed with a callback that just updates the toolbar buttons when the display command panel is changed? I've just tried it and it works. I was obviously thinking about it in the wrong way with trying to merge the callback stuff INTO the macroscript somehow. That's made me think about it a different way. Thank you.

MarcoBrunetta
03-25-2008, 10:27 PM
Wouldnīt it be easier to just press Shift+G ?

3rd Dimentia
03-26-2008, 03:45 AM
I do use Shift-G. The buttons on my toolbar are mainly a hide by category display so show what IS hidden by category without having to change the command panel. Not everyone would find them useful, but I do.

http://home.iprimus.com.au/wickergray/hbc.jpg

So after all that I have my callback working. I've just dropped this code into a .ms and put it into my script/startup directory. It all seems to be working how I want it to, but is the scripts/startup the right spot for this?


callbacks.removescripts id:#CgToolbarUpdate
fn HideByCategoryUpdate =
(
updateToolbarButtons()
)
callbacks.addscript #byCategoryDisplayFilterChanged "HideByCategoryUpdate()" id:#CgToolbarUpdate

CGTalk Moderation
03-26-2008, 03:45 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.