File tree 2 files changed +23
-22
lines changed
2 files changed +23
-22
lines changed Original file line number Diff line number Diff line change @@ -97,14 +97,33 @@ resize(VALUE self)
97
97
YEXCEPTION_CATCH
98
98
}
99
99
100
+ /*
101
+ * Extend wait_for_event with ability to process event in block.
102
+ * @yield [event] pass raised event to block
103
+ * @yield_param [UI::Event] event that occur
104
+ * @yield_return [true,false] response if dialog should continue in waiting
105
+ * for another event
106
+ * @example change button label
107
+ * dialog.wait_for_event do |event|
108
+ * break unless event.is_a? UI::WidgetEvent
109
+ * event.widget[:Label] = "Already pressed"
110
+ * true
111
+ * end
112
+ */
100
113
static VALUE
101
114
wait_for_event (VALUE self)
102
115
{
103
116
YEXCEPTION_TRY
117
+
104
118
YDialog *ptr = ui_unwrap_dialog (self);
105
119
new CallbackFilter (ptr); // see filter documentation
106
- YEvent * ev = ptr->waitForEvent ();
107
- return convert_event (ev);
120
+ YEvent *ev = 0L ;
121
+ do {
122
+ ev = ptr->waitForEvent ();
123
+ if (!rb_block_given_p ())
124
+ return convert_event (ev);
125
+ } while (rb_yield (convert_event (ev)) != Qfalse);
126
+
108
127
YEXCEPTION_CATCH
109
128
}
110
129
Original file line number Diff line number Diff line change 1
1
module UI
2
2
class Dialog
3
- alias_method :wait_for_event_c , :wait_for_event
3
+
4
4
class << self
5
5
alias_method :current , :current_dialog
6
6
end
7
- # extend wait_for_event with ability to process event in block.
8
- # @yield [event] pass raised event to block
9
- # @yield_param [UI::Event] event that occur
10
- # @yield_return [true,false] response if dialog should continue in waiting
11
- # for another event
12
- # @example change button label
13
- # dialog.wait_for_event do |event|
14
- # break unless event.is_a? UI::WidgetEvent
15
- # event.widget[:Label] = "Already pressed"
16
- # true
17
- # end
18
- def wait_for_event ( options = { } )
19
- if block_given?
20
- while ( yield ( wait_for_event_c ) ) do
21
- end
22
- else
23
- return wait_for_event_c
24
- end
25
- end
7
+
26
8
end
27
9
end
You can’t perform that action at this time.
0 commit comments