Toolbar Event

Just starting out? Need help? Post your questions and find answers here.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Toolbar Event

Post 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.
Windows 7 & PureBasic 4.4
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Toolbat buttons can't receive focus.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

No? Damn it, would have been a nice feature :x
Thanks anyway...
Windows 7 & PureBasic 4.4
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

I think you mean when the mouse hover over them?
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Yes, that's what I meant :)
Windows 7 & PureBasic 4.4
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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
Last edited by srod on Tue May 15, 2007 4:13 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Hi,
I searched the MSDN but didn't find any Toolbar messages at all. :cry:
But thanks for your snippet anyway :)
Windows 7 & PureBasic 4.4
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

I think you need to subclass it.
r_hyde
Enthusiast
Enthusiast
Posts: 155
Joined: Wed Jul 05, 2006 12:40 am

Post 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.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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."
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post 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 :twisted:
Windows 7 & PureBasic 4.4
r_hyde
Enthusiast
Enthusiast
Posts: 155
Joined: Wed Jul 05, 2006 12:40 am

Post 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 :wink:

As for #3, I can only echo what milan1612 said.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post 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" :wink:
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

milan1612 wrote:That's Microsofts opinion :twisted:
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.
Post Reply