Hi,
I’m trying to get something done using the MBS Toolbar but I can’t make it work. I have close to zero experience with MBS so any help is welcome.
The (now previous version of the) iTunes Toolbar has this ‘Sign In’ thingy:
When not logged in, it says ‘Sign In’. When logged in, it shows the username.
I found that NSPopupButtonMBS gives me the down arrow and doesn’t show an inverted background when clicked.
So with this:
Sub Constructor()
NSPopupButtonMBS
Super.Constructor(0, 0, 100, 24)
Me.isBordered = False
Me.pullsDown = True
Me.addItemsWithTitles(Array(" ")) // Blank
// Add Image
Dim m As NSMenuItemMBS = Me.itemAtIndex(0)
m.Image = New NSImageMBS(pUser)
m.Image.setSize(14, 14)
m.Image.IsTemplate = True
// The Title
m.Title = "Hello2"
End Sub
I end up with this:
Pretty close but I have two issues:
This NSPopUpButtonMBS is meant to show a popup menu. However, I would like to leave the items blank and only catch the MouseDown so I can open a new Window.
I have no clue on how to catch the MouseDown. I assume I need NSEventMBS to set AddHandler but where and how do I set that?
The Text can be ‘Sign In’, ‘John’ or ‘AVeryLongNickName’. How can I adjust the 100 width so the down arrow is positioned nicely next to the name? Or better yet, is there some autosize/align way to do this?
[quote=267404:@Marco Hof]- This NSPopUpButtonMBS is meant to show a popup menu. However, I would like to leave the items blank and only catch the MouseDown so I can open a new Window.
I have no clue on how to catch the MouseDown. I assume I need NSEventMBS to set AddHandler but where and how do I set that?[/quote]
You can do this with a popup menu and some declares, this way you would still have access to the mouseDown event. I use this event to display nested menus in a Popup menu.
StringWidth and some manual addition. There can be some conflict in sizes as you need to set the min and max size for the toolbar item.
Personally, if I look at the iTunes interface, I don’t think that they used a toolbar. I think this is just controls at the top of the window and then the right APIs to hide the window title (and adjust the height). This would give you far more flexibility and make it easier to do what you want to do.
Interesting. But would that look the same then? And the next challenge then comes up on how to place that on an MBS Toolbar.
I was afraid of that. It’s no problem to do it that way but I’d hoped that there was something less of a hassle though. Something build in already.
[quote]
Personally, if I look at the iTunes interface, I don’t think that they used a toolbar. I think this is just controls at the top of the window and then the right APIs to hide the window title (and adjust the height). This would give you far more flexibility and make it easier to do what you want to do.[/quote]
Good point. And I tried.
I tried both declares I found on the Forum to place controls on a regular Toolbar and just using a Metal Window with a canvas on top.
This Metal Window actually looked very promising but I ended up with too much band-aids. From little things like normal dragging of the Window, gesture dragging etc. But I also use Save/Open sheet dialogs, preference sheet etc.
In the end, I figured that using MBS was going to be easier. Just need to figure out how things work though.
To place a PopupMenu on to a regular toolbar you have to get the handle to the control and assign it to the toolbar item (via declares). I’m sure MBS has this function.
setView:
Metal Windows are no longer used by Apple, so I wouldn’t imagine that they’d get supported for much longer. With Yosemite (shudder) Apple added some functions for remove the titlebar and shifting the controls up into the top of the window.
Look for similar functions in the MBS suite.
window.titleVisibility = NSWindowTitle.Hidden
window.titlebarAppearsTransparent = true
window.styleMask = window.styleMask + NSFullSizeContentViewWindowMask
I wrote an article about this back in xDev issue 12.5
Well, I could add code to catch more events there.
But as you use a NSMenuMBS, you can use the classes and when EnableMenuItems or WillOpen Events come on the menu subclass, you know the menu is open.
[quote=267434:@Christian Schmitz]Well, I could add code to catch more events there.
But as you use a NSMenuMBS, you can use the classes and when EnableMenuItems or WillOpen Events come on the menu subclass, you know the menu is open.[/quote]
Christian, I’m trying really hard to use your plugin as how it’s supposed to work but somehow I don’t get it.
I tried adding a NSMenuMBS Class (and I see the events) but then I can’t seem to use it in NSPopupButtonMBS. I think I fail to see how it all stitches together.
This is stripped down to what I have now.
All I’m looking for is a MouseDown (a-like) event that I can use to open a new Window. Can you please help me out so I understand how that’s done?
Using a normal button with picture and text (with isBordered = False) doesn’t seem to work.
For example, I don’t see a way to align (left or X=0) the picture. And I can align the title right, left, center but not set the X position. So it seems impossible to place them like in the example in my first post.
(And another issue it that when clicked, the background inverts.)