… | |
… | |
51 | } |
51 | } |
52 | |
52 | |
53 | sub on_button_release { |
53 | sub on_button_release { |
54 | my ($self, $event) = @_; |
54 | my ($self, $event) = @_; |
55 | |
55 | |
56 | if ($event->{button} == $self->{data}{event}{button}) { |
|
|
57 | $self->ungrab; |
|
|
58 | $self->destroy; |
|
|
59 | } |
|
|
60 | |
|
|
61 | $self->{press}[$event->{button}] = 0; |
56 | $self->{press}[$event->{button}] = 0; |
62 | |
57 | |
63 | my ($row, $col) = ($event->{row}, $event->{col}); |
58 | my ($row, $col) = ($event->{row}, $event->{col}); |
64 | if ($col >= 0 && $col < $self->ncol |
59 | if ($col >= 0 && $col < $self->ncol |
65 | && $row >= 0 && $row < @{ $self->{data}{item} }) { |
60 | && $row >= 0 && $row < @{ $self->{data}{item} }) { |
66 | my $item = $self->{data}{item}[$row]; |
61 | my $item = $self->{data}{item}[$row]; |
67 | $item->{activate}->($event, $item); |
62 | $item->{activate}->($event, $item); |
68 | } |
63 | } |
69 | |
64 | |
70 | $self->refresh; |
65 | $self->refresh; |
|
|
66 | |
|
|
67 | if ($event->{button} == $self->{data}{event}{button}) { |
|
|
68 | $self->ungrab; |
|
|
69 | $self->destroy; |
|
|
70 | } |
71 | |
71 | |
72 | 1 |
72 | 1 |
73 | } |
73 | } |
74 | |
74 | |
75 | sub on_focus_out { |
75 | sub on_focus_out { |
… | |
… | |
86 | |
86 | |
87 | my $data = $self->{data} = $urxvt::popup::self; |
87 | my $data = $self->{data} = $urxvt::popup::self; |
88 | |
88 | |
89 | $_->{width} = $self->strwidth ($_->{text}) |
89 | $_->{width} = $self->strwidth ($_->{text}) |
90 | for @{ $data->{item} }; |
90 | for @{ $data->{item} }; |
|
|
91 | |
|
|
92 | $self->resource (title => "URxvt Popup Menu"); |
|
|
93 | $self->resource (name => "URxvt.popup"); |
91 | |
94 | |
92 | $self->resource ($_ => $data->{term}->resource ($_)) |
95 | $self->resource ($_ => $data->{term}->resource ($_)) |
93 | for qw(font boldFont italicFont boldItalicFont color+0 color+1); |
96 | for qw(font boldFont italicFont boldItalicFont color+0 color+1); |
94 | |
97 | |
95 | my $width = List::Util::max map $_->{width}, @{ $data->{item} }; |
98 | my $width = List::Util::max map $_->{width}, @{ $data->{item} }; |