Re: Fw: Right-click menu and selection in CList

Hi Bhaskar,

"Bhaskar S. Manda" wrote:


I have a menu that pops up when the right mouse button is clicked on a 
CList. I have some questions about this.

1. How do I select the row on which the right-button is clicked? 
Retrieving the mouse co-ordinates and then using those the find out 
which row is selected seems  like too many steps. I tried instead to 
make the right button select (in addition to the left button), but it 
isn't having any effect on the mouse actions. This is the call I am using
   $some_CList->set_button_actions(3, [ 0,1,0,0 ]);
I think I am making some mistake in using the enum ButtonAction. 
The desired effect I want is for the row (on which somebody right clicks)
to be selected (that is, highlighted, as if the left button was clicked 
on it), and in addition I want the on_clist_button_press callback to be
activated just like it is now, so that I can pop the menu. Once some 
action is selected from the menu, I can use clist-selection to retrieve 
the selected row(s) and process them.
In a on_clist1_button_press_event I usually do:
    my ($row, $col);
    my $ctree = $form->{$object};
    ($row, $col) = $ctree->get_selection_info($event->{'x'}, $event->{'y'});
    $ctree->select_row($row, 0);

to select the line whatever button the user pressed.

2. I'm using Glade-Perl and I always have a difficulty getting pointers 
to the widgets in the packages that it generates for each window and 
pop-up menu. In the case above, I want to do something like $menu->popup 
on a right-click. I end up doing this - I put the menu in a different 
file On right-click, I call   $menu = SomeMenu->new. The
difference is I change the SomeMenu package from that generated by
Glade-Perl by returning $widgets from it instead of $self. Is there a 
clean way to get to the menu widgets from the all_forms hash? Simply
scoping it (SomeMenu::all_forms) doesn't work.
I usually do it the other way round. I send a ref to the form that
called the original signal handler to the right-click menu the handler
in the right-click menu class can update the main form. So for example:
    my $cform = new clist_right_menu;  # Or whatever class
    $cform->{'__LINKDATA'} = $d;       # Hash of linknodes keyed by ref
    $cform->{'__FROMFORM'} = $form;    # Our form with clist1
    $cform->{'__FROMINSTANCE'} = $instance;
        undef, undef, $event->{'button'}, $event->{'time'}, undef);

and then in clist_right_menu->on_expand_this_activate() do:
sub on_expand_this_activate {
  my ($class, $data, $object, $instance, $event) = @_;
  my $me = __PACKAGE__."->on_expand_this_activate";
  # Get ref to hash of all widgets on our form
  my $form = $__PACKAGE__::all_forms->{$instance};


} # End of sub on_expand_this_activate

Another way is to connect the signals for clist_right_menu by hand and 
use closures for the right-menu handlers.

3. Anybody know of a Perl binding for GtkSheet? Dermot, the link you 
sent is for GtkTextExtra, not GtkExtra which has this widget :)
Sorry, my mistake :(

HTH, Dermot

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