On Wed, Nov 27, 2013 at 07:06:13PM +0100, Thorsten Wißmann wrote:
> On Wed, Nov 27, 2013 at 03:09:45PM +0100, Raphaël wrote:
> > > Quite possibly, use the 'Right Mouse Button' for backing out of a record 
> > > and 
> > > into the list view.  Also could use the 'Right Mouse Button' for escaping 
> > > an 
> > > entry being edited. In other words, make 'ESC' = 'Right Mouse Button'.
> > 
> > I myself don't use mouse support a lot, has Thorsten any opinion about this 
> > ?
> 
> To be as close as possible to the behaviour of ordinary GUI Applications
> abook should cancel editing if the user clicks anywhere outside the text
> box (in particular when right-clicking somehwere).

It turned out to be much more difficult than expected, because the
prompt in the bottom line directly is readline. And I can't access the
main loop of readline(). (I think that it is not worth rewriting it)

> By the way I used the title "abook-currentversion" on the top left as
> the escape button (but not yet when editing some entry). And it's also
> not mentioned in the man page. I can write patches for all three issues
> later, if it's OK for you.

I described the First-Row-Behaviour in the attached
0001-Describe-first-row-clicking-in-abookrc.5.patch -- please merge or
improve it :)

Regarding the Right-Clicking: When binding the right mouse button, then
it is not possible to access the right-click menu of your terminal
emulator. Having the first-row-trick, the right-click-escape feature
is not very intuitive and annoying for the context-menu-users, IMO. If
you want to play with it anyway, just try the attached patch
0002-Let-mouse-right-click-behave-like-the-escape-key.patch but I don't
think it should be merged. Maybe making it configurable solves these
problems. Opions?

Regards,
Thorsten
From c2019efd822f4ff1bb844b1c14ff4b122f7f6db1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= <e...@thorsten-wissmann.de>
Date: Wed, 27 Nov 2013 22:51:06 +0100
Subject: [PATCH 1/2] Describe first-row-clicking in abookrc.5

Describe what happens when having the mouse enabled and clicking into
the first row of the abook ui.
---
 abookrc.5 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/abookrc.5 b/abookrc.5
index ba12c7c..3df6654 100644
--- a/abookrc.5
+++ b/abookrc.5
@@ -148,7 +148,7 @@ Defines if the cursor is visible in main display. Default is false.
 
 .TP
 \fBuse_mouse\fP=[true|false]
-Defines if navigation via the mouse is activated. Default is false. Most terminals can also inhibit ncurses mouse events at runtime by holding the Shift key (restoring mouse-selection behavior).
+Defines if navigation via the mouse is activated. Default is false. Most terminals can also inhibit ncurses mouse events at runtime by holding the Shift key (restoring mouse-selection behavior). Clicking into the first row of the terminal behaves as pressing escape. It exits the current view.
 
 .TP
 \fBscroll_speed\fP=lines
-- 
1.8.4.2

From 15a3cd61f93dd9431bb4feb9e9de78970df40cd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= <e...@thorsten-wissmann.de>
Date: Wed, 27 Nov 2013 23:08:37 +0100
Subject: [PATCH 2/2] Let mouse right-click behave like the escape key

Just a first commit to play with the right-click-feature. The
documentation for it is missing.
---
 edit.c | 6 +++++-
 ui.c   | 9 +++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/edit.c b/edit.c
index 9a76c8a..8febeea 100644
--- a/edit.c
+++ b/edit.c
@@ -676,7 +676,11 @@ edit_loop(int item)
 	if(c == KEY_MOUSE) {
 		MEVENT event;
 		if(getmouse(&event) == OK) {
-			if(event.bstate & BUTTON1_CLICKED
+			if(event.bstate & BUTTON3_CLICKED
+			   || event.bstate & BUTTON3_DOUBLE_CLICKED) {
+			   /* Right click behaves as pressing escape */
+			   return -1;
+			} else if(event.bstate & BUTTON1_CLICKED
 			   || event.bstate & BUTTON1_DOUBLE_CLICKED) {
 				int window_y, window_x;
 				getbegyx(editw, window_y, window_x);
diff --git a/ui.c b/ui.c
index e879885..3383b68 100644
--- a/ui.c
+++ b/ui.c
@@ -151,7 +151,7 @@ ui_enable_mouse(bool enabled)
 {
 	mmask_t mask;
 	if(enabled) {
-		mask = BUTTON1_CLICKED | BUTTON4_PRESSED;
+		mask = BUTTON1_CLICKED | BUTTON3_CLICKED | BUTTON4_PRESSED;
 #if NCURSES_MOUSE_VERSION == 2
 		mask |= BUTTON5_PRESSED;
 #endif
@@ -544,9 +544,14 @@ get_commands()
 			MEVENT event;
 			bool double_clicked = was_double_click();
 			if(getmouse(&event) == OK) {
-				if(event.bstate & BUTTON1_CLICKED
+				if(event.bstate & BUTTON3_CLICKED
+				   || event.bstate & BUTTON3_DOUBLE_CLICKED) {
+					/* right click behaves like the  escape key */
+					return;
+				} else if(event.bstate & BUTTON1_CLICKED
 				   || event.bstate & BUTTON1_DOUBLE_CLICKED) {
 					if(event.y == 0) {
+						/* clicking the first row behaves like the escape key */
 						return;
 					}
 					list_set_curitem(event.y + list_get_firstitem() - LIST_TOP);
-- 
1.8.4.2

Attachment: pgpvXulXXnCiv.pgp
Description: PGP signature

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Abook-devel mailing list
Abook-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/abook-devel

Reply via email to