aboutsummaryrefslogtreecommitdiffstats
path: root/lib/gs/doc/src/examples/ex7.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
committerErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /lib/gs/doc/src/examples/ex7.erl
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'lib/gs/doc/src/examples/ex7.erl')
-rw-r--r--lib/gs/doc/src/examples/ex7.erl42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/gs/doc/src/examples/ex7.erl b/lib/gs/doc/src/examples/ex7.erl
new file mode 100644
index 0000000000..a80c36fdcb
--- /dev/null
+++ b/lib/gs/doc/src/examples/ex7.erl
@@ -0,0 +1,42 @@
+-module(ex7).
+-copyright('Copyright (c) 1991-97 Ericsson Telecom AB').
+-vsn('$Revision: /main/release/2 $ ').
+
+-export([mk_window/0]).
+
+mk_window() ->
+ S= gs:start(),
+ Win= gs:create(window,S,[{motion,true},{map,true}]),
+ gs:config(Win,[{configure,true},{keypress,true}]),
+ gs:config(Win,[{buttonpress,true}]),
+ gs:config(Win,[{buttonrelease,true}]),
+ event_loop(Win).
+
+event_loop(Win) ->
+ receive
+ {gs,Win,motion,Data,[X,Y | Rest]} ->
+ %% mouse moved to position X Y
+ io:format("mouse moved to X:~w Y:~w~n",[X,Y]);
+ {gs,Win,configure,Data,[W,H | Rest]} ->
+ %% window was resized by user
+ io:format("window resized W:~w H:~w~n",[W,H]);
+ {gs,Win,buttonpress,Data,[1,X,Y | Rest]} ->
+ %% button 1 was pressed at location X Y
+ io:format("button 1 pressed X:~w Y:~w~n",[X,Y]);
+ {gs,Win,buttonrelease,Data,[_,X,Y | Rest]} ->
+ %% Any button (1-3) was released over X Y
+ io:format("Any button released X:~w Y:~w~n",[X,Y]);
+ {gs,Win,keypress,Data,[a | Rest]} ->
+ %% key `a' was pressed in window
+ io:format("key a was pressed in window~n");
+ {gs,Win,keypress,Data,[_,65,1 | Rest]} ->
+ %% Key shift-a
+ io:format("shift-a was pressed in window~n");
+ {gs,Win,keypress,Data,[c,_,_,1 | Rest]} ->
+ %% CTRL_C pressed
+ io:format("CTRL_C was pressed in window~n");
+ {gs,Win,keypress,Data, ['Return' | Rest]} ->
+ %% Return key pressed
+ io:format("Return key was pressed in window~n")
+ end,
+ event_loop(Win).