Page 1 of 3
Toolbar Event
Posted: Tue May 15, 2007 2:39 pm
by milan1612
Does anybody know how to receive a event from a Toolbarbutton?
I want to display some text in a Statusbar when a Toolbarbutton is focused.
I'm using the PB Standard Toolbar. Thanks for any suggestions.
Posted: Tue May 15, 2007 2:52 pm
by Trond
Toolbat buttons can't receive focus.
Posted: Tue May 15, 2007 3:05 pm
by milan1612
No? Damn it, would have been a nice feature
Thanks anyway...
Posted: Tue May 15, 2007 3:09 pm
by Trond
I think you mean when the mouse hover over them?
Posted: Tue May 15, 2007 3:27 pm
by milan1612
Yes, that's what I meant

Posted: Tue May 15, 2007 3:30 pm
by Trond
Keep in mind that status bars are for showing status and not tooltips.
This is the closest I get.
Code: Select all
Procedure Callback(WindowID, Message, wParam, lParam)
Protected Result = #PB_ProcessPureBasicEvents
If Message = #WM_NOTIFY
StatusBarText(0, 0, "Toolbar hover")
EndIf
ProcedureReturn Result
EndProcedure
OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
SmartWindowRefresh(0, 1)
CreateGadgetList(WindowID(0))
CreateToolBar(0, WindowID(0))
ToolBarStandardButton(0, 0)
ToolBarStandardButton(1, 1)
ToolBarStandardButton(2, 2)
ToolBarStandardButton(3, 3)
ToolBarStandardButton(4, 4)
CreateStatusBar(0, WindowID(0))
SetWindowCallback(@Callback())
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
Break
Case 675
StatusBarText(0, 0, "")
EndSelect
ForEver
Posted: Tue May 15, 2007 4:03 pm
by srod
You can always use the #TB_GETHOTITEM message in combination with #WM_MOUSEMOVE.
The following conversion of Danillo's ToolBar pro library to PB source shows how it might be done. (See example program 1 or indeed the source for the nxMouseOverTBbutton() function.)
http://www.purebasic.fr/english/viewtop ... =nxtoolbar
Posted: Tue May 15, 2007 4:03 pm
by milan1612
Hi,
I searched the MSDN but didn't find any Toolbar messages at all.
But thanks for your snippet anyway

Posted: Tue May 15, 2007 4:15 pm
by Trond
I think you need to subclass it.
Posted: Tue May 15, 2007 8:03 pm
by r_hyde
Trond wrote:Keep in mind that status bars are for showing status and not tooltips.
It's not at all uncommon for an application to show a brief tooltip giving the name of the command, and a more detailed usage message on the statusbar. This is especially handy when button functionality changes due to context or the application of modifier keys (shift, alt, etc.). There is absolutely nothing wrong with using the statusbar in this way.
Posted: Tue May 15, 2007 8:50 pm
by Trond
r_hyde wrote:Trond wrote:Keep in mind that status bars are for showing status and not tooltips.
It's not at all uncommon for an application to show a brief tooltip giving the name of the command, and a more detailed usage message on the statusbar. This is especially handy when button functionality changes due to context or the application of modifier keys (shift, alt, etc.). There is absolutely nothing wrong with using the statusbar in this way.
1. Not uncommon <> Good
2. If button functionality changes due to context then the user interface is seriously flawed and needs a re-design and a new UI designer.
3. Toolbar buttons are short-cuts for menu items. The Windows Vista User Experience Guidelines explicitly says to not use the status bar for explaining menu items: "Don't use the status bar to explain menu bar items."
Posted: Tue May 15, 2007 9:12 pm
by milan1612
In wxWidgets, a popular C++ UI Framework, a Statusbar is always
used to explain the Toolbar Items.
3. Toolbar buttons are short-cuts for menu items. The Windows Vista User Experience Guidelines explicitly says to not use the status bar for explaining menu items: "Don't use the status bar to explain menu bar items."
That's Microsofts opinion

Posted: Tue May 15, 2007 11:16 pm
by r_hyde
Trond wrote:1. Not uncommon <> Good
Just as uncommon <> bad. There's no absolute standard here.
Trond wrote:2. If button functionality changes due to context then the user interface is seriously flawed and needs a re-design and a new UI designer.
It might be flawed, or maybe not. Again, this is not an absolute--it depends upon the purpose and design of the application, and upon how thoughtfully the idea is employed. Under the right conditions, context-aware controls can make for a powerful, flexible, and intuitive interface. Otherwise, I'll concede it's possible that they might only confuse the user. If you're going to use the paradigm, though, one good step to avoiding end-user confusion is to provide some kind of indication--a status message, perhaps
As for #3, I can only echo what milan1612 said.
Posted: Wed May 16, 2007 12:26 am
by fsw
Trond wrote:
...The Windows Vista User Experience Guidelines explicitly says to not use the status bar for explaining menu items: "Don't use the status bar to explain menu bar items."
Yeah, it' better to use TOOLTIPS for that.
Usage:
Move mouse cursor over a toolbar button.
It just takes a few seconds to show the tooltip....
Here it is.
Thanks to the tooltip, now I know it's the wrong toolbar button.
Try next toolbar button...
It just takes a few seconds to show the tooltip....
Here it is.
Thanks to the tooltip, now I know it's the wrong toolbar button.
Try next toolbar button...
In the statusbar the hint/tip is instantaneous.
Way better "User Experience"

Posted: Wed May 16, 2007 8:53 am
by Trond
milan1612 wrote:That's Microsofts opinion

It's their operating system...
fsw, if you can't see what the toolbar buttons does from their image, then the image is not good enough and might as well be replaced with a text-only button. This will enable you to know what it does without moving your mouse over it. WAY better user experience. Especially if you have difficulties using a mouse because you are somehow disabled.