← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2142: text-box menu fixes

 

------------------------------------------------------------
revno: 2142
committer: poy <poy@xxxxxxxxxx>
branch nick: repo
timestamp: Mon 2010-05-10 18:55:43 +0200
message:
  text-box menu fixes
modified:
  dwt/include/dwt/aspects/AspectKeyboard.h
  dwt/src/widgets/TextBox.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/AspectKeyboard.h'
--- dwt/include/dwt/aspects/AspectKeyboard.h	2010-02-11 21:44:13 +0000
+++ dwt/include/dwt/aspects/AspectKeyboard.h	2010-05-10 16:55:43 +0000
@@ -107,8 +107,10 @@
 template< class WidgetType >
 class AspectKeyboard : public AspectKeyboardBase
 {
+	const WidgetType& W() const { return *static_cast<const WidgetType*>(this); }
 	WidgetType& W() { return *static_cast<WidgetType*>(this); }
-	HWND H() { return W().handle(); }
+
+	HWND H() const { return W().handle(); }
 
 	typedef Dispatchers::VoidVoid<0, false> FocusDispatcher;
 

=== modified file 'dwt/src/widgets/TextBox.cpp'
--- dwt/src/widgets/TextBox.cpp	2010-05-10 15:48:54 +0000
+++ dwt/src/widgets/TextBox.cpp	2010-05-10 16:55:43 +0000
@@ -128,8 +128,17 @@
 }
 
 ClientCoordinate TextBoxBase::ptFromPos(int pos) {
-	DWORD res = sendMessage(EM_POSFROMCHAR, pos);
-	return ClientCoordinate(Point(LOWORD(res), HIWORD(res)), this);
+	LRESULT res = sendMessage(EM_POSFROMCHAR, pos);
+	Point pt;
+	if(res == -1) {
+		Point sz = getClientSize();
+		pt.x = sz.x / 2;
+		pt.y = sz.y / 2;
+	} else {
+		pt.x = LOWORD(res);
+		pt.y = HIWORD(res);
+	}
+	return ClientCoordinate(pt, this);
 }
 
 void TextBoxBase::scrollToBottom() {
@@ -198,6 +207,9 @@
 }
 
 bool TextBoxBase::handleMessage(const MSG& msg, LRESULT& retVal) {
+	if(msg.message == WM_RBUTTONDOWN && !hasFocus())
+		setFocus();
+
 	bool handled = BaseType::handleMessage(msg, retVal);
 
 	// keep the scroll position at the end if it already was at the end