1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302 | %%
%% |_¯ \ / |_¯ |\ | ¯|¯
%% W X |__ V |__ | \| | . E R L
%%————————————————————————————————————
%%
%% Copyright Ericsson AB 2008-2013. All Rights Reserved.
%%
%%——————————————————————————————————————————————
%% Whitespace Beautified by ScriptCulture © 2018
%% Sit Back · Feet Up · Learn wxErlang
%% For use as a reference only
%% www.scriptculture.com
%% Not check-summed
%% wx 1.8 ——————————————————————————————————————
%%
%% Licensed under the Apache License,
%% Version 2.0 (the "License"); you may
%% not use this file except in compliance
%% with the License. You may obtain a copy
%% of the License at:
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by
%% applicable law or agreed to in writing, software
%% distributed under the License is distributed
%% on an "AS IS" BASIS, WITHOUT WARRANTIES
%% OR CONDITIONS OF ANY KIND, either
%% express or implied. See the
%% License for the specific
%% language governing
%% permissions and
%% limitations
%% under the
%% License.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% OVERVIEW
%% ––––––––
%% An event is a structure holding information about an
%% event passed to a callback or member function.
%%
%% wxEvent used to be a multipurpose event object,
%% and is an abstract base class for other event classes (see below).
%%
%% For more information about events,
%% see the Event handling overview.
%%
%%
%% See Also:
%% —————————
%% wxCommandEvent,
%% wxMouseEvent
%%
%%
-module(wxEvent).
-include("wxe.hrl").
-export([
getId/1,
getSkipped/1,
getTimestamp/1,
isCommandEvent/1,
stopPropagation/1,
resumePropagation/2,
shouldPropagate/1,
skip/1,
skip/2
]).
%% inherited exports
-export([parent_class/1]).
-export_type([wxEvent/0]).
%% @hidden
parent_class(_Class) -> erlang:error({badtype, ?MODULE}).
-type wxEvent() :: wx:wx_object().
%·%% GET ID %%·%
%%
%% Returns the identifier associated with this event,
%% such as a button command id.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec getId(This) -> integer()
when
This :: wxEvent().
getId(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxEvent),
wxe_util:call(?wxEvent_GetId,
<<ThisRef:32/?UI>>).
%·%% GET SKIPPED %%·%
%%
%% Returns true if the event handler should be skipped,
%% false otherwise.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec getSkipped(This) -> boolean()
when
This :: wxEvent().
getSkipped(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxEvent),
wxe_util:call(?wxEvent_GetSkipped,
<<ThisRef:32/?UI>>).
%·%% GET TIMESTAMP %%·%
%%
%% Gets the timestamp for the event.
%% The timestamp is the time in milliseconds since
%% some fixed moment (not necessarily the standard Unix
%% Epoch, so only differences between the timestamps and not
%% their absolute values usually make sense).
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec getTimestamp(This) -> integer()
when
This :: wxEvent().
getTimestamp(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxEvent),
wxe_util:call(?wxEvent_GetTimestamp,
<<ThisRef:32/?UI>>).
%·%% IS COMMAND EVENT %%·%
%%
%% Returns true if the event is or is derived from
%% wxCommandEvent else it returns false.
%%
%% Note: Exists only for optimization purposes.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec isCommandEvent(This) -> boolean()
when
This :: wxEvent().
isCommandEvent(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxEvent),
wxe_util:call(?wxEvent_IsCommandEvent,
<<ThisRef:32/?UI>>).
%·%% STOP PROPAGATION %%·%
%%
%% Stop the event from propagating to its parent window.
%%
%% Returns the old propagation level value which may be
%% later passed to ResumePropagation to allow propagating
%% the event again.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec stopPropagation(This) -> integer()
when
This :: wxEvent().
stopPropagation(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxEvent),
wxe_util:call(?wxEvent_StopPropagation,
<<ThisRef:32/?UI>>).
%·%% RESUME PROPAGATION %%·%
%%
%% Sets the propagation level to the given value
%% (for example returned from an earlier call to StopPropagation).
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec resumePropagation(This, PropagationLevel) -> ok
when
This :: wxEvent(),
PropagationLevel :: integer().
resumePropagation(#wx_ref{ type=ThisT,ref=ThisRef },
PropagationLevel)
when is_integer(PropagationLevel) ->
?CLASS(ThisT,wxEvent),
wxe_util:cast(?wxEvent_ResumePropagation,
<<ThisRef:32/?UI,PropagationLevel:32/?UI>>).
%·%% SHOULD PROPAGATE %%·%
%%
%% Test if this event should be propagated or not,
%% i.e. if the propagation level is currently greater than 0.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec shouldPropagate(This) -> boolean()
when
This :: wxEvent().
shouldPropagate(#wx_ref{type=ThisT,ref=ThisRef}) ->
?CLASS(ThisT,wxEvent),
wxe_util:call(?wxEvent_ShouldPropagate,
<<ThisRef:32/?UI>>).
%·%% SKIP %%·%
%%
%% See below...
%% @equiv skip(This, [])
-spec skip(This) -> ok
when
This :: wxEvent().
skip(This)
when
is_record(This, wx_ref) -> skip(This, []).
%%
%% This method can be used inside an event handler to control
%% whether further event handlers bound to this event will be
%% called after the current one returns.
%%
%% || Without Skip() (or EQUIVALENTLY if Skip(false) is used), ||
%% || the event will not be processed any more. ||
%%
%% If Skip(true) is called, the event processing system continues
%% searching for a further handler function for this event,
%% even though it has been processed already in the current handler.
%%
%% —— In general, it is recommended to skip all non-command events
%% to allow the default handling to take place. ——
%%
%% The command events are, however, normally not skipped
%% as usually a single command such as a button click or menu
%% item selection must only be processed by one handler.
%%
%% Return Value:
%% See Also:
%%*%%*%%
-spec skip(This, [Option]) -> ok
when
This :: wxEvent(),
Option :: {skip, boolean()}.
skip(#wx_ref{type=ThisT,ref=ThisRef}, Options)
when
is_list(Options) ->
?CLASS(ThisT,wxEvent),
MOpts = fun({ skip, Skip}, Acc) -> [<<1:32/?UI,(wxe_util:from_bool(Skip)):32/?UI>>|Acc];
( BadOpt, _ ) -> erlang:error({badoption, BadOpt})
end,
BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
wxe_util:cast(?wxEvent_Skip,
<<ThisRef:32/?UI, 0:32,BinOpt/binary>>).
|