Re: [gtk-list] Re: gtktext/popup menu problem





I am having a similar problem with the clist widget in 1.2.0.  I used to 
be able to right click and have a popup menu activate in 1.0.6.  Now, I
discovered that the 1.2.x clist only responds to the 1st mouse button.  I
have hacked support for the 2nd and 3rd mouse buttons.  However, when I
popup menu.. it never gets focus from the mouse.  I have to press a key to
get the menu.  To make matters interesting the popup menu acts this way in
browse mode.  In other modes I have different problems.. I would like to
use browse.

I am using the "select_row" signal in clist.  Does this have the same
issue as the text widget example below?

I am using the perl bindings.  One of my questions is how to return FALSE
in the Perl bindings?  I am not sure that this works yet in the perl
bindings.  

Jon Allen

On 7 May 1999, Owen Taylor wrote:

> 
> Timo Sirainen <a@sicom.fi> writes:
> 
> > I'm trying to create a popup menu which items depends of what word in
> > text
> > widget I clicked, but there's a problem:
>  
> > After creating popup menu when clicking text widget with right mouse
> > button, selecting text doesn't work anymore (it shows as gray).
> > That's because I use gtk_signal_connect_after() to grab
> > button_press_event.  And I need to use that to make
> > gtk_editable_get_position() return the right position (where I just
> > clicked in text widget). I could handle all this in
> > button_release_event, but creating menus in button_release_event
> > works a bit weird.. I really can't think of any way to fix this.
> 
> If you are going to do a popup menu on a text widget, then
> you have the responsibility to make sure that either the text widget
> sees both the press and the release, or neither.
> 
> Since you are popping up the menu, it isn't going to see the
> release - which is why you are leaving it in an inconsistent
> state.
> 
> So you want to:
> 
>  1) gtk_signal_connect (not after) to the button_press_signal
>  2a) if event->button != 3, return FALSE
>  2b) if event->button == 3, call
>        gtksignal_emit_stop_by_name (widget, "button_press_event");
>      pop up the menu and return TRUE.
> 
> This is the only correct way to handle popups on a widget
> that also handles events itself. Now, the question is how do 
> you map from cursor position to character in the buffer.
> 
> This is one of the many things that _should_ be in the Text
> widget API, and would be, if the code was half maintainable.
> 
> As a hack, you can probably do pretty much what you are
> doing now - synthesize a (button 1) press/release pair
> a the position of button 3 click to move the cursor, then
> check where the cursor is. (You can send them with
> gtk_widget_event())
> 
> The main thing to note here is that button presses that
> a widget sees _must_ be paired.
> 
> Regards,
>                                         Owen
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 
> 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]