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

Re: how do I tell which widget has the selection



rob <mailingLists@pangolin.org.uk> writes:
> I have a window which contains mostly gtkEntry widgets and a toolbar
> with the usuale cut copy paste buttons. When the user clicks
> cut/copy i want to cut/copy text from widget that has the selection
> (i.e has the blue highlighted look) to the clipboard but I can't
> figure out how to tell what (if any) widget has it.
> 

Not sure of the official way but this may work:

 GdkWindow *window;
 GtkWidget *widget;

 window = gdk_selection_owner_get (GDK_SELECTION_PRIMARY);

 if (window)
    widget = gdk_window_get_user_data (window);
 else
    widget = NULL;

You still have the problem that you have to write code like this:

  if (widget)
    {
      if (GTK_IS_EDITABLE (widget))
        /* cut/copy for GtkEditable *; 
      else if (GTK_IS_SOMETHING_ELSE (widget))
         ;
      ...
    }

GTK should probably have a solution to that, but it doesn't.

Havoc





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