forked from AuroraMiddleware/gtk
label: Be more selective when selecting on focus-in
We don't want to select on focus-in when the focus
comes from a child. The case where this does harm
is when you activate copy or paste actions from the
context menu. We close the menu before triggering the
action, and if that causes the text in the label to
be selected, unexpected things happen, since the action
applies to the current selection.
This is the equivalent of cd9f5733b3
for GtkLabel.
This commit is contained in:
parent
2a962e1c9a
commit
64ed69c56f
@ -3710,10 +3710,13 @@ gtk_label_grab_focus (GtkWidget *widget)
|
||||
{
|
||||
GtkLabel *self = GTK_LABEL (widget);
|
||||
gboolean select_on_focus;
|
||||
GtkWidget *prev_focus;
|
||||
|
||||
if (self->select_info == NULL)
|
||||
return FALSE;
|
||||
|
||||
prev_focus = gtk_root_get_focus (gtk_widget_get_root (widget));
|
||||
|
||||
if (!GTK_WIDGET_CLASS (gtk_label_parent_class)->grab_focus (widget))
|
||||
return FALSE;
|
||||
|
||||
@ -3724,12 +3727,14 @@ gtk_label_grab_focus (GtkWidget *widget)
|
||||
&select_on_focus,
|
||||
NULL);
|
||||
|
||||
if (select_on_focus && !self->in_click)
|
||||
if (select_on_focus && !self->in_click &&
|
||||
!(prev_focus && gtk_widget_is_ancestor (prev_focus, widget)))
|
||||
gtk_label_select_region (self, 0, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (self->select_info->links && !self->in_click)
|
||||
if (self->select_info->links && !self->in_click &&
|
||||
!(prev_focus && gtk_widget_is_ancestor (prev_focus, widget)))
|
||||
{
|
||||
guint i;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user