← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2495: reorganize click notifications

 

------------------------------------------------------------
revno: 2495
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2011-04-16 17:22:56 +0200
message:
  reorganize click notifications
removed:
  dwt/include/dwt/aspects/AspectDblClickable.h
modified:
  dwt/include/dwt/aspects/AspectClickable.h
  dwt/include/dwt/widgets/Button.h
  dwt/include/dwt/widgets/ComboBox.h
  dwt/include/dwt/widgets/DateTime.h
  dwt/include/dwt/widgets/GroupBox.h
  dwt/include/dwt/widgets/Label.h
  dwt/include/dwt/widgets/StatusBar.h
  dwt/include/dwt/widgets/Table.h
  dwt/include/dwt/widgets/Tree.h
  dwt/src/widgets/StatusBar.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dwt/include/dwt/aspects/AspectClickable.h'
--- dwt/include/dwt/aspects/AspectClickable.h	2011-01-02 17:12:02 +0000
+++ dwt/include/dwt/aspects/AspectClickable.h	2011-04-16 15:22:56 +0000
@@ -40,28 +40,26 @@
 
 namespace dwt {
 
-/// Aspect class used by Widgets that have the possibility of being "clicked".
-/** \ingroup AspectClasses
-  * E.g. the Button have a "clicked" Aspect therefore it realizes the
-  * AspectClickable through inheritance. When you click a Widget which realizes this
-  * Aspect the onClicked event will be raised.
-  */
-template< class WidgetType >
-class AspectClickable
-{
+/// Aspect class used by controls that handle clicks (mouse-down / mouse-up).
+template<class WidgetType>
+class AspectClickable {
 	WidgetType& W() { return *static_cast<WidgetType*>(this); }
-	typedef Dispatchers::VoidVoid<> ClickableDispatcher;
+	typedef Dispatchers::VoidVoid<> Dispatcher;
 
 public:
-	/// \ingroup EventHandlersAspectClickable
-	/// Setting the event handler for the "clicked" event
-	/** All Widgets that realize this Aspect will raise this event when Widget is
-	  * being "clicked". To be clicked differs from Widget types, for a button it is
-	  * pressing the button and releasing it, for another Widget it might be
-	  * something else. No parameters are passed.
-	  */
-	void onClicked(const typename ClickableDispatcher::F& f) {
-		W().addCallback(WidgetType::getClickMessage(), ClickableDispatcher(f));
+	/// register a function to be called after a left click.
+	void onClicked(const typename Dispatcher::F& f) {
+		W().addCallback(WidgetType::getClickMessage(), Dispatcher(f));
+	}
+
+	/// register a function to be called after a right click.
+	void onRightClicked(const typename Dispatcher::F& f) {
+		W().addCallback(WidgetType::getRightClickMessage(), Dispatcher(f));
+	}
+
+	/// register a function to be called after a double-click.
+	void onDblClicked(const Dispatcher::F& f) {
+		W().addCallback(WidgetType::getDblClickMessage(), Dispatcher(f));
 	}
 
 protected:

=== removed file 'dwt/include/dwt/aspects/AspectDblClickable.h'
--- dwt/include/dwt/aspects/AspectDblClickable.h	2011-01-02 17:12:02 +0000
+++ dwt/include/dwt/aspects/AspectDblClickable.h	1970-01-01 00:00:00 +0000
@@ -1,71 +0,0 @@
-/*
-  DC++ Widget Toolkit
-
-  Copyright (c) 2007-2011, Jacek Sieka
-
-  SmartWin++
-
-  Copyright (c) 2005 Thomas Hansen
-
-  All rights reserved.
-
-  Redistribution and use in source and binary forms, with or without modification,
-  are permitted provided that the following conditions are met:
-
-      * Redistributions of source code must retain the above copyright notice,
-        this list of conditions and the following disclaimer.
-      * Redistributions in binary form must reproduce the above copyright notice,
-        this list of conditions and the following disclaimer in the documentation
-        and/or other materials provided with the distribution.
-      * Neither the name of the DWT nor SmartWin++ nor the names of its contributors
-        may be used to endorse or promote products derived from this software
-        without specific prior written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef DWT_AspectDblClickable_h
-#define DWT_AspectDblClickable_h
-
-#include "../Dispatchers.h"
-
-namespace dwt {
-
-/// \ingroup AspectClasses
-/// Aspect class used by Widgets that have the possibility of being "Double
-/// Clicked".
-/** E.g. the Label have a "Double Clicked" Aspect therefore it realizes the
-  * AspectDblClickable through inheritance.
-  */
-template< class WidgetType >
-class AspectDblClickable
-{
-	WidgetType& W() { return *static_cast<WidgetType*>(this); }
-	typedef Dispatchers::VoidVoid<> DblClickableDispatcher;
-public:
-	/// \ingroup EventHandlersAspectDblClickable
-	/// Setting the event handler for the "Double Clicked" event
-	/** All Widgets that realize this Aspect will raise this event when Widget is
-	  * being Double Clicked. No parameters are passed.
-	  */
-
-	void onDblClicked(const DblClickableDispatcher::F& f) {
-		W().addCallback(WidgetType::getDblClickMessage(), DblClickableDispatcher(f));
-	}
-
-protected:
-	virtual ~AspectDblClickable() { }
-};
-
-}
-
-#endif

=== modified file 'dwt/include/dwt/widgets/Button.h'
--- dwt/include/dwt/widgets/Button.h	2011-01-02 17:12:02 +0000
+++ dwt/include/dwt/widgets/Button.h	2011-04-16 15:22:56 +0000
@@ -38,7 +38,6 @@
 
 #include "../aspects/AspectColor.h"
 #include "../aspects/AspectClickable.h"
-#include "../aspects/AspectDblClickable.h"
 #include "../aspects/AspectText.h"
 #include "Control.h"
 
@@ -50,13 +49,12 @@
 	public AspectClickable<Button>,
 	public AspectColor<Button>,
 	public AspectColorCtlImpl<Button>,
-	public AspectDblClickable<Button>,
 	public AspectText< Button >
 {
 	typedef CommonControl BaseType;
 	friend class AspectClickable<Button>;
-	friend class AspectDblClickable<Button>;
 	friend class WidgetCreator<Button>;
+
 public:
 	/// Class type
 	typedef Button ThisType;
@@ -97,20 +95,17 @@
 	friend class ChainingDispatcher;
 	static const TCHAR windowClass[];
 
-	// Contract needed by AspectClickable Aspect class
+	// AspectClickable
 	static Message getClickMessage();
-
-	// Contract needed by AspectDblClickable Aspect class
 	static Message getDblClickMessage();
-
 };
 
 inline Message Button::getClickMessage() {
-	return Message( WM_COMMAND, MAKEWPARAM(0, BN_CLICKED) );
+	return Message(WM_COMMAND, MAKEWPARAM(0, BN_CLICKED));
 }
 
 inline Message Button::getDblClickMessage() {
-	return Message( WM_COMMAND, MAKEWPARAM(0, BN_DBLCLK) );
+	return Message(WM_COMMAND, MAKEWPARAM(0, BN_DBLCLK));
 }
 
 inline Button::Button(Widget* parent) :

=== modified file 'dwt/include/dwt/widgets/ComboBox.h'
--- dwt/include/dwt/widgets/ComboBox.h	2011-03-15 19:52:17 +0000
+++ dwt/include/dwt/widgets/ComboBox.h	2011-04-16 15:22:56 +0000
@@ -40,7 +40,6 @@
 #include "../aspects/AspectClickable.h"
 #include "../aspects/AspectCollection.h"
 #include "../aspects/AspectData.h"
-#include "../aspects/AspectDblClickable.h"
 #include "../aspects/AspectSelection.h"
 #include "../aspects/AspectText.h"
 #include "../util/check.h"
@@ -64,7 +63,6 @@
 	public AspectColor< ComboBox >,
 	public AspectColorCtlImpl<ComboBox>,
 	public AspectData<ComboBox, int>,
-	public AspectDblClickable< ComboBox >,
 	public AspectSelection< ComboBox, int >,
 	public AspectText< ComboBox >
 {
@@ -75,7 +73,6 @@
 	friend class AspectSelection<ComboBox, int>;
 	friend class AspectClickable<ComboBox>;
 	friend class AspectData<ComboBox, int>;
-	friend class AspectDblClickable<ComboBox>;
 
 public:
 	/// Class type
@@ -158,33 +155,28 @@
 	LPARAM getDataImpl(int i);
 	void setDataImpl(int i, LPARAM data);
 
-	// Aspect expectation implementation
-	static const Message& getSelectionChangedMessage();
-
-	// Aspect expectation implementation
-	static const Message& getClickMessage();
-
-	// Aspect expectation implementation
-	static const Message& getDblClickMessage();
+	// AspectSelection
+	static Message getSelectionChangedMessage();
+
+	// AspectClickable
+	static Message getClickMessage();
+	static Message getDblClickMessage();
 };
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Implementation of class
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-inline const Message& ComboBox::getSelectionChangedMessage() {
-	static const Message retVal( WM_COMMAND, CBN_SELENDOK );
-	return retVal;
-}
-
-inline const Message& ComboBox::getClickMessage() {
-	static const Message retVal( WM_COMMAND, CBN_DROPDOWN );
-	return retVal;
-}
-
-inline const Message& ComboBox::getDblClickMessage() {
-	static const Message retVal( WM_COMMAND, CBN_DBLCLK );
-	return retVal;
+inline Message ComboBox::getSelectionChangedMessage() {
+	return Message(WM_COMMAND, CBN_SELENDOK);
+}
+
+inline Message ComboBox::getClickMessage() {
+	return Message(WM_COMMAND, CBN_DROPDOWN);
+}
+
+inline Message ComboBox::getDblClickMessage() {
+	return Message(WM_COMMAND, CBN_DBLCLK);
 }
 
 inline int ComboBox::getSelectedImpl() const {

=== modified file 'dwt/include/dwt/widgets/DateTime.h'
--- dwt/include/dwt/widgets/DateTime.h	2011-01-02 17:12:02 +0000
+++ dwt/include/dwt/widgets/DateTime.h	2011-04-16 15:22:56 +0000
@@ -205,7 +205,7 @@
 	friend class ChainingDispatcher;
 	static const TCHAR windowClass[];
 
-	// Aspect expectation implementation
+	// AspectClickable
 	static Message getClickMessage();
 };
 
@@ -214,7 +214,7 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 inline Message DateTime::getClickMessage() {
-	return Message( WM_NOTIFY, DTN_DROPDOWN );
+	return Message(WM_NOTIFY, DTN_DROPDOWN);
 }
 
 inline SYSTEMTIME DateTime::getDateTime()

=== modified file 'dwt/include/dwt/widgets/GroupBox.h'
--- dwt/include/dwt/widgets/GroupBox.h	2011-03-15 19:52:17 +0000
+++ dwt/include/dwt/widgets/GroupBox.h	2011-04-16 15:22:56 +0000
@@ -45,9 +45,7 @@
   * add up your RadioButtons into an object of this type
   */
 #include "../aspects/AspectColor.h"
-#include "../aspects/AspectClickable.h"
 #include "../aspects/AspectChild.h"
-#include "../aspects/AspectDblClickable.h"
 #include "../aspects/AspectText.h"
 #include "Control.h"
 

=== modified file 'dwt/include/dwt/widgets/Label.h'
--- dwt/include/dwt/widgets/Label.h	2011-03-15 19:52:17 +0000
+++ dwt/include/dwt/widgets/Label.h	2011-04-16 15:22:56 +0000
@@ -38,7 +38,6 @@
 
 #include "../aspects/AspectColor.h"
 #include "../aspects/AspectClickable.h"
-#include "../aspects/AspectDblClickable.h"
 #include "../aspects/AspectText.h"
 #include "Control.h"
 
@@ -62,13 +61,12 @@
 	public AspectClickable< Label >,
 	public AspectColor< Label >,
 	public AspectColorCtlImpl<Label>,
-	public AspectDblClickable< Label >,
 	public AspectText< Label >
 {
 	typedef CommonControl BaseType;
 	friend class WidgetCreator< Label >;
 	friend class AspectClickable<Label>;
-	friend class AspectDblClickable<Label>;
+
 public:
 	/// Class type
 	typedef Label ThisType;
@@ -117,19 +115,17 @@
 	friend class ChainingDispatcher;
 	static const TCHAR windowClass[];
 
-	// Contract needed by AspectClickable Aspect class
-	static Message getClickMessage();
-
-	// Contract needed by AspectDblClickable Aspect class
+	// AspectClickable
+	static Message getLeftClickMessage();
 	static Message getDblClickMessage();
 };
 
-inline Message Label::getClickMessage() {
-	return Message( WM_COMMAND, MAKEWPARAM(0, STN_CLICKED) );
+inline Message Label::getLeftClickMessage() {
+	return Message(WM_COMMAND, MAKEWPARAM(0, STN_CLICKED));
 }
 
 inline Message Label::getDblClickMessage() {
-	return Message( WM_COMMAND, MAKEWPARAM(0, STN_DBLCLK) );
+	return Message(WM_COMMAND, MAKEWPARAM(0, STN_DBLCLK));
 }
 
 inline Label::Label( Widget * parent )

=== modified file 'dwt/include/dwt/widgets/StatusBar.h'
--- dwt/include/dwt/widgets/StatusBar.h	2011-03-15 21:16:24 +0000
+++ dwt/include/dwt/widgets/StatusBar.h	2011-04-16 15:22:56 +0000
@@ -36,8 +36,6 @@
 #ifndef DWT_StatusBar_h
 #define DWT_StatusBar_h
 
-#include "../aspects/AspectClickable.h"
-#include "../aspects/AspectDblClickable.h"
 #include "Control.h"
 
 #include <vector>
@@ -59,19 +57,10 @@
   * process you are currently etc...
   */
 class StatusBar :
-	public CommonControl,
-
-	// Aspects
-	public AspectClickable<StatusBar>,
-	public AspectDblClickable<StatusBar>
+	public CommonControl
 {
 	typedef CommonControl BaseType;
-	typedef AspectClickable<StatusBar> ClickType;
-	typedef AspectDblClickable<StatusBar> DblClickType;
-
 	friend class WidgetCreator<StatusBar>;
-	friend class AspectClickable<StatusBar>;
-	friend class AspectDblClickable<StatusBar>;
 
 	typedef Dispatchers::VoidVoid<>::F F;
 
@@ -132,6 +121,7 @@
 	void mapWidget(unsigned part, Widget* widget, const Rectangle& padding = Rectangle(0, 0, 0, 0));
 
 	void onClicked(unsigned part, const F& f);
+	void onRightClicked(unsigned part, const F& f);
 	void onDblClicked(unsigned part, const F& f);
 
 	/// Actually creates the StatusBar
@@ -154,18 +144,12 @@
 	virtual ~StatusBar()
 	{}
 
-	// Contract needed by AspectClickable Aspect class
-	static Message getClickMessage() { return Message(WM_NOTIFY, NM_CLICK); }
-
-	// Contract needed by AspectDblClickable Aspect class
-	static Message getDblClickMessage() { return Message(WM_NOTIFY, NM_DBLCLK); }
-
 private:
 	friend class ChainingDispatcher;
 	static const TCHAR windowClass[];
 
 	struct Part {
-		Part() : size(0), icon(0), helpId(0), clickF(0), dblClickF(0) { }
+		Part() : size(0), icon(0), helpId(0), clickF(0), rightClickF(0), dblClickF(0) { }
 
 		unsigned size;
 
@@ -176,6 +160,7 @@
 		unsigned helpId;
 
 		F clickF;
+		F rightClickF;
 		F dblClickF;
 
 		void updateSize(StatusBar* bar, bool alwaysResize);
@@ -195,6 +180,7 @@
 
 	void handleToolTip(tstring& text);
 	void handleClicked();
+	void handleRightClicked();
 	void handleDblClicked();
 
 	// AspectHelp

=== modified file 'dwt/include/dwt/widgets/Table.h'
--- dwt/include/dwt/widgets/Table.h	2011-03-15 19:52:17 +0000
+++ dwt/include/dwt/widgets/Table.h	2011-04-16 15:22:56 +0000
@@ -43,7 +43,6 @@
 #include "../aspects/AspectCollection.h"
 #include "../aspects/AspectColor.h"
 #include "../aspects/AspectData.h"
-#include "../aspects/AspectDblClickable.h"
 #include "../aspects/AspectScrollable.h"
 #include "../aspects/AspectSelection.h"
 #include "Control.h"
@@ -75,7 +74,6 @@
 	public AspectCollection<Table, int>,
 	public AspectColor<Table>,
 	public AspectData<Table, int>,
-	public AspectDblClickable< Table >,
 	public AspectScrollable< Table >,
 	public AspectSelection< Table, int >
 {
@@ -102,7 +100,6 @@
 	friend class AspectData<Table, int>;
 	friend class AspectSelection<Table, int>;
 	friend class AspectClickable<Table>;
-	friend class AspectDblClickable<Table>;
 
 public:
 	/// Class type
@@ -553,14 +550,11 @@
 	int getSelectedImpl() const;
 	void setSelectedImpl( int idx );
 	size_t countSelectedImpl() const;
-
-	// Aspect expectation implementation
 	static Message getSelectionChangedMessage();
 
-	// Contract needed by AspectClickable Aspect class
+	// AspectClickable
 	static Message getClickMessage();
-
-	// Contract needed by AspectDblClickable Aspect class
+	static Message getRightClickMessage();
 	static Message getDblClickMessage();
 };
 
@@ -569,15 +563,19 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 inline Message Table::getSelectionChangedMessage() {
-	return Message( WM_NOTIFY, LVN_ITEMCHANGED );
+	return Message(WM_NOTIFY, LVN_ITEMCHANGED);
 }
 
 inline Message Table::getClickMessage() {
-	return Message( WM_NOTIFY, NM_CLICK );
+	return Message(WM_NOTIFY, NM_CLICK);
+}
+
+inline Message Table::getRightClickMessage() {
+	return Message(WM_NOTIFY, NM_RCLICK);
 }
 
 inline Message Table::getDblClickMessage() {
-	return Message( WM_NOTIFY, NM_DBLCLK );
+	return Message(WM_NOTIFY, NM_DBLCLK);
 }
 
 #ifdef PORT_ME

=== modified file 'dwt/include/dwt/widgets/Tree.h'
--- dwt/include/dwt/widgets/Tree.h	2011-01-02 17:12:02 +0000
+++ dwt/include/dwt/widgets/Tree.h	2011-04-16 15:22:56 +0000
@@ -42,7 +42,6 @@
 #include "../aspects/AspectCollection.h"
 #include "../aspects/AspectColor.h"
 #include "../aspects/AspectData.h"
-#include "../aspects/AspectDblClickable.h"
 #include "../aspects/AspectSelection.h"
 #include "Control.h"
 
@@ -78,10 +77,10 @@
 	public AspectCollection<Tree, HTREEITEM>,
 	public AspectColor<Tree>,
 	public AspectData<Tree, HTREEITEM>,
-	public AspectDblClickable< Tree >,
 	public AspectSelection< Tree, HTREEITEM >
 {
 	typedef CommonControl BaseType;
+
 protected:
 	struct Dispatcher
 	{
@@ -109,7 +108,6 @@
 	friend class AspectData<Tree, HTREEITEM>;
 	friend class AspectSelection<Tree, HTREEITEM>;
 	friend class AspectClickable<Tree>;
-	friend class AspectDblClickable<Tree>;
 
 public:
 	/// Class type
@@ -303,15 +301,12 @@
 	HTREEITEM getSelectedImpl() const;
 	void setSelectedImpl( HTREEITEM item );
 	size_t countSelectedImpl() const;
-
-	// Contract needed by AspectClickable Aspect class
-	static const Message & getSelectionChangedMessage();
-
-	// Contract needed by AspectClickable Aspect class
-	static const Message& getClickMessage();
-
-	// Contract needed by AspectDblClickable Aspect class
-	static const Message& getDblClickMessage();
+	static Message getSelectionChangedMessage();
+
+	// AspectClickable
+	static Message getClickMessage();
+	static Message getRightClickMessage();
+	static Message getDblClickMessage();
 };
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -413,19 +408,20 @@
 	this->Widget::addRemoveStyle( TVS_EDITLABELS, value );
 }
 
-inline const Message & Tree::getSelectionChangedMessage() {
-	static const Message retVal( WM_NOTIFY, TVN_SELCHANGED );
-	return retVal;
-}
-
-inline const Message & Tree::getClickMessage() {
-	static const Message retVal( WM_NOTIFY, NM_CLICK );
-	return retVal;
-}
-
-inline const Message & Tree::getDblClickMessage() {
-	static const Message retVal( WM_NOTIFY, NM_DBLCLK );
-	return retVal;
+inline Message Tree::getSelectionChangedMessage() {
+	return Message(WM_NOTIFY, TVN_SELCHANGED);
+}
+
+inline Message Tree::getClickMessage() {
+	return Message(WM_NOTIFY, NM_CLICK);
+}
+
+inline Message Tree::getRightClickMessage() {
+	return Message(WM_NOTIFY, NM_RCLICK);
+}
+
+inline Message Tree::getDblClickMessage() {
+	return Message(WM_NOTIFY, NM_DBLCLK);
 }
 
 inline HTREEITEM Tree::getSelectedImpl() const {

=== modified file 'dwt/src/widgets/StatusBar.cpp'
--- dwt/src/widgets/StatusBar.cpp	2011-03-23 20:26:21 +0000
+++ dwt/src/widgets/StatusBar.cpp	2011-04-16 15:22:56 +0000
@@ -70,9 +70,6 @@
 
 	tip = WidgetCreator<ToolTip>::create(this, ToolTip::Seed());
 	tip->setTool(this, [this](tstring& text) { handleToolTip(text); });
-
-	ClickType::onClicked([this] { handleClicked(); });
-	DblClickType::onDblClicked([this] { handleDblClicked(); });
 }
 
 void StatusBar::setSize(unsigned part, unsigned size) {
@@ -137,11 +134,25 @@
 void StatusBar::onClicked(unsigned part, const F& f) {
 	dwtassert(part < parts.size(), _T("Invalid part number."));
 	parts[part].clickF = f;
+
+	// imitate the default onClicked but with a setCallback.
+	setCallback(Message(WM_NOTIFY, NM_CLICK), Dispatchers::VoidVoid<>([this] { handleClicked(); }));
+}
+
+void StatusBar::onRightClicked(unsigned part, const F& f) {
+	dwtassert(part < parts.size(), _T("Invalid part number."));
+	parts[part].rightClickF = f;
+
+	// imitate the default onRightClicked but with a setCallback.
+	setCallback(Message(WM_NOTIFY, NM_RCLICK), Dispatchers::VoidVoid<>([this] { handleRightClicked(); }));
 }
 
 void StatusBar::onDblClicked(unsigned part, const F& f) {
 	dwtassert(part < parts.size(), _T("Invalid part number."));
 	parts[part].dblClickF = f;
+
+	// imitate the default onDblClicked but with a setCallback.
+	setCallback(Message(WM_NOTIFY, NM_DBLCLK), Dispatchers::VoidVoid<>([this] { handleDblClicked(); }));
 }
 
 int StatusBar::refresh() {
@@ -237,6 +248,12 @@
 		part->clickF();
 }
 
+void StatusBar::handleRightClicked() {
+	Part* part = getClickedPart();
+	if(part && part->rightClickF)
+		part->rightClickF();
+}
+
 void StatusBar::handleDblClicked() {
 	Part* part = getClickedPart();
 	if(part && part->dblClickF)