aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/test/wx_obj_test.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2016-03-30 09:48:30 +0200
committerDan Gudmundsson <[email protected]>2016-04-22 09:17:40 +0200
commita3a5bcab69695b7bfe8a77f4c1b245a1b58fb5fb (patch)
tree803fc2446613b3f32dbcd81ce4b65b42564fb685 /lib/wx/test/wx_obj_test.erl
parente0a67398ad3d034e1afe59585a5f82af6981c1eb (diff)
downloadotp-a3a5bcab69695b7bfe8a77f4c1b245a1b58fb5fb.tar.gz
otp-a3a5bcab69695b7bfe8a77f4c1b245a1b58fb5fb.tar.bz2
otp-a3a5bcab69695b7bfe8a77f4c1b245a1b58fb5fb.zip
wx: add object set/check funcions
Needed functionality, to avoid abusing opauqe objects.
Diffstat (limited to 'lib/wx/test/wx_obj_test.erl')
-rw-r--r--lib/wx/test/wx_obj_test.erl11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/wx/test/wx_obj_test.erl b/lib/wx/test/wx_obj_test.erl
index cf99728c1a..23142e28b2 100644
--- a/lib/wx/test/wx_obj_test.erl
+++ b/lib/wx/test/wx_obj_test.erl
@@ -19,13 +19,13 @@
-module(wx_obj_test).
-include_lib("wx/include/wx.hrl").
--export([start/1, stop/1]).
+-export([start/1, stop/1, who_are_you/1]).
%% wx_object callbacks
-export([init/1, handle_info/2, terminate/2, code_change/3, handle_call/3,
handle_sync_event/3, handle_event/2, handle_cast/2]).
--record(state, {parent, opts, user_state}).
+-record(state, {parent, me, opts, user_state}).
start(Opts) ->
wx_object:start_link(?MODULE, [{parent, self()}| Opts], []).
@@ -33,12 +33,15 @@ start(Opts) ->
stop(Object) ->
wx_object:stop(Object).
+who_are_you(Object) ->
+ wx_object:call(Object, who_are_you).
+
init(Opts) ->
Parent = proplists:get_value(parent, Opts),
put(parent_pid, Parent),
Init = proplists:get_value(init, Opts),
{Obj, UserState} = Init(),
- {Obj, #state{parent=Parent, opts=Opts, user_state=UserState}}.
+ {Obj, #state{me=Obj, parent=Parent, opts=Opts, user_state=UserState}}.
handle_sync_event(Event = #wx{obj=Panel, event=#wxPaint{}},
WxEvent, #state{parent=Parent, user_state=US, opts=Opts}) ->
@@ -59,6 +62,8 @@ handle_event(Event, State = #state{parent=Parent}) ->
Parent ! {event, Event},
{noreply, State}.
+handle_call(who_are_you, _From, State = #state{me=Me}) ->
+ {reply, Me, State};
handle_call(What, From, State = #state{user_state=US}) when is_function(What) ->
Result = What(US),
{reply, {call, Result, From}, State};