Xojo Conferences
XDCMay2019MiamiUSA

[MBS] how to use NSCustomToolbarItemMBS.menuFormRepresentation? (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] [ANN] 17.2pr3
Next thread: [MBS] [ANN] 17.2pr2


Re: [MBS] AuthorizationMBS   -   Garth Hjelte
  [MBS] how to use NSCustomToolbarItemMBS.menuFormRepresentation?   -   James Sentman
   Re: [MBS] how to use NSCustomToolbarItemMBS.menuFormRepresentation?   -   james sentman.com

[MBS] how to use NSCustomToolbarItemMBS.menuFormRepresentation?
Date: 07.04.17 17:12 (Fri, 7 Apr 2017 12:12:21 -0400)
From: James Sentman
I have several toolbars that use the custom controls in toolbar technique to embed buttons and other controls in the toolbar. It’s basically just reusing most of your ToolBar buttons example. The problem I’m having is when the window is too small to hold the entire toolbar and changes some into menu items to popup on the right hand side.

If I don’t change the NSCustomToolbarItemMBS.view to the NSButtonMBS then the menus work and the event falls through to the NSCUstomToolbarItemMBS’s action event as it does in the simpler toolbar example. Once I set the .view of the toolbaritem though the menu seems out of my control and no longer sends my toolbarItem class it’s event.

I attempted to create an NSMenuItemMBS subclass and assign that to the menuFormRepresentation property of the toolitem and that works as far as being able to enable and disable the menu as well as change it’s title, but the event still doesn’t filter down to the new class. The Action event of the NSMenuItemMBS subclass is never called.

is it just a problem with my understanding of how to catch those events?

Thanks,
James

James Sentman http://www.PlanetaryGear.org http://MacHomeAutomation.com



_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] how to use NSCustomToolbarItemMBS.menuFormRepresentation?
Date: 07.04.17 17:44 (Fri, 7 Apr 2017 12:44:18 -0400)
From: james sentman.com

And as usual I realized my misunderstanding a very short time after posting to the list :)

The problem is that the xojo object is separate from the NSMenuItem as far as the system is concerned and if you’re going to subclass the menu and set the menuFormRepresentation you have to keep a local reference to the menu subclass in order for it to work. As soon as I did that I started getting events from my menu subclass.

I still don’t know why it’s necessary to do that and not just trap the menu event in the CustomNSToolBarItemMBS class as happens before you change the .view property, but this is a workAround for the moment.

> On Apr 7, 2017, at 12:12 PM, James Sentman <<email address removed>> wrote:
>
> I attempted to create an NSMenuItemMBS subclass and assign that to the menuFormRepresentation property of the toolitem and that works as far as being able to enable and disable the menu as well as change it’s title, but the event still doesn’t filter down to the new class. The Action event of the NSMenuItemMBS subclass is never called.

Thanks,
James

James Sentman http://www.PlanetaryGear.org http://MacHomeAutomation.com



_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info