.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

what event does the syatem trigger when close a palette(my own palette)

8 REPLIES 8
Reply
Message 1 of 9
yaqiz
1393 Views, 8 Replies

what event does the syatem trigger when close a palette(my own palette)

Hi Guys,

 

I am using VB.net created a palette。 I need to call refresh drawing(my own function) when user close this palette. But I don't know which event I need to put my code in

 

Any ideas?

 

Thanks very much

8 REPLIES 8
Message 2 of 9
norman.yuan
in reply to: yaqiz

Do you mean closing a PaletteSet, or a Palette in a PaletteSet (if so, how your code let user to close a Palette in a PaletteSet? Set the user control invisible, or remove the user control from the PaletteSet)?

 

For the former, PaletteSet fires an event "PaletteSetStateChanged" when its visibility is changed. That is, when user click the "x" on the even fires. So, you can handle this event with information provided in the PaletteSetStateChangedeventArgs.

 

For the latter, you may have to derive your PaletteSet from PaletteSet class and create your own event when user control is added/removed to the PaletteSet, or when the user control's visibility changed. Note, PaletteSet is inheritable only since Acad2009.

 

Also, since PletteSet is a modeless window, it seems odd that you need to "refresh" (by regenerating?) the drawing on its closing. Usually, the drawing should be updated right after the change is done in the paletteset if the change affects the drawing. "Update drawing after winodw closiing" is usually applied to modal window.

Message 3 of 9
yaqiz
in reply to: norman.yuan

Thanks for your reply.

 

I meant to close paletteset. on the palette there are 2 buttons on the top right corner. one looks like "-", the other one looks like "x". "-" is for hide and "x" is for close. click either button can trigger statechange event, but new state all =hide.

I would like to do something when user click "x" but not "-"

 

any ideas ?

 

 

Thanks again

Message 4 of 9
norman.yuan
in reply to: yaqiz

Teh StateChanged event always fires when click "x" at the top corner of the PaletteSet.

 

However, clicking "-" to set "auto-hide" on or off that causes the PaletteSet to be hidden partially (e.g. the PaletteSet's window bar is still visible while its working area is hidden. Iin this case, it is arguable to say a PaletteSet is visible or not :-() would cause the StateChanged event firing or not firing, depending on if the PaletteSet is docked or not.

 

In my test, if the PaletteSet is floating (not docked), then when the main part of the PaletteSet becomes hidden (automatically after mouse cursor leaves from it a few seconds), the StateChange event will not fire. When puttiing mouse cursor onto the PaletteSet's winodws bar to cause the PaletteSet working area being shown, the StateChange event also does not fire. That is, when the PaletteSet is floating, StateChanged event only fires when user click "x" or when your code to set PaletteSet.Visible=true.

 

When the PaletteSet is docked, clicking both "x" and "-" cuases StateChanged event fire with NewState index as "Hide". But "x" set entire PaletteSet invisible, while "-" leave the PaletteSet's window bar still docked and visible (auto-hide). Placing mouse curosr on the docked PaletteSet window bar causes the PaletteSet's work area poping out and StateChanged event firing with NewState index as "Show". However, when the PaletteSet's work area automatically hides back, no StateChanged event fires.

 

So, if you need to do something when the PaletteSet becomes fully invisible (clicked "x") or partially (auto-hiding), you need to do it depending on if the PaletteSet is docked or not, by examing PaletteSet.Dock property.

Message 5 of 9
yaqiz
in reply to: norman.yuan

Thanks for your reply.

 

I did the same testing. if the paletteset is docked. the first time I click "-" fires statechange and make the paletteset autohide. "x" also fires stagechange and make the paletteset fully invisible. There is no way I can tell the different between those 2 clicks. At least I didn't find any.

 

Any ideas?

 

Thanks

Message 6 of 9
yaqiz
in reply to: yaqiz

What I meant is between the first click "hide" and "close" when paletteset docked they both trigger event statechange and both pass new state =hide.

Message 7 of 9
Artvegas
in reply to: yaqiz

I don't think you can tell the difference between "hide" and "close" events.

 

Only thing I can think of is to provide your own close button and hide the close button from your PaletteSet. To do this you can set the PaletteSet Style property and omit the PaletteSetStyles.ShowCloseButton enumeration, e.g. in C#:

 

ps.Style = PaletteSetStyles.NameEditable |
                    PaletteSetStyles.ShowPropertiesMenu |
                    PaletteSetStyles.ShowAutoHideButton;

 

Hope this helps.

Message 8 of 9
yaqiz
in reply to: Artvegas

Thanks for your reply

 

That what I am doing now. Using my own button

 

Thanks again

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost