aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/test/wx_event_SUITE.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2013-08-27 10:46:51 +0200
committerDan Gudmundsson <[email protected]>2013-08-27 10:46:51 +0200
commit475402a87c2e2e59c6ff24e68f740e5eb2ef9077 (patch)
tree2cdf7102aa987704ff94d64634959a61382d9311 /lib/wx/test/wx_event_SUITE.erl
parente627c554272f3690bffbae0f34692b29c720e89e (diff)
downloadotp-475402a87c2e2e59c6ff24e68f740e5eb2ef9077.tar.gz
otp-475402a87c2e2e59c6ff24e68f740e5eb2ef9077.tar.bz2
otp-475402a87c2e2e59c6ff24e68f740e5eb2ef9077.zip
wx: Add character event test/example
Diffstat (limited to 'lib/wx/test/wx_event_SUITE.erl')
-rw-r--r--lib/wx/test/wx_event_SUITE.erl26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/wx/test/wx_event_SUITE.erl b/lib/wx/test/wx_event_SUITE.erl
index 53a2ee7d7b..f19adb430d 100644
--- a/lib/wx/test/wx_event_SUITE.erl
+++ b/lib/wx/test/wx_event_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -47,7 +47,9 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
[connect, disconnect, connect_msg_20, connect_cb_20,
- mouse_on_grid, spin_event, connect_in_callback, recursive].
+ mouse_on_grid, spin_event, connect_in_callback, recursive,
+ char_events
+ ].
groups() ->
[].
@@ -398,3 +400,23 @@ recursive(Config) ->
wx_test_lib:flush(),
wx_test_lib:wx_destroy(Frame, Config).
+
+
+char_events(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
+char_events(Config) ->
+ Wx = wx:new(),
+ Frame = wxFrame:new(Wx, ?wxID_ANY, "Press any key"),
+ Panel = wxPanel:new(Frame, []),
+ wxFrame:connect(Frame, enter_window, [{callback, fun(_,_) ->
+ io:format("Set focus~n"),
+ wxWindow:setFocus(Panel)
+ end}]),
+ KeyEvent = fun(Ev,Obj) -> io:format("Got ~p~n",[Ev]), wxEvent:skip(Obj) end,
+ [wxWindow:connect(Panel, Types, [{callback,KeyEvent}])
+ || Types <- [key_down, key_up, char]],
+ wxWindow:connect(Frame, char_hook, [{callback,KeyEvent}]),
+
+ wxFrame:show(Frame),
+ wx_test_lib:flush(),
+
+ wx_test_lib:wx_destroy(Frame, Config).