wx_object(3erl)
๐
wx_object โ Erlang Module Definition ๐
okay bestie, this is the manual page for wx_object(3erl) โ we're folding that manual name right in here so the header line doesn't have to be copy-pasted, periodt. โจ
๐ธ NAME ๐ธ
wx_object - wx_object - Generic wx object behaviour. ๐
โจ DESCRIPTION โจ
wx_object - Generic wx object behaviour ๐ฆ
This is a behaviour module that can be used for "sub classing" wx objects. It works like a regular gen_server module and creates a server per object. ๐
NOTE: Currently no form of inheritance is implemented. ๐จ not me expecting inheritance and getting none ๐ญ
The user module should export:
init(Args) should return
{wxObject, State} | {wxObject, State, Timeout} | ignore | {stop, Reason}
Asynchronous window event handling:
handle_event(#wx{}, State) should return
{noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}
The user module can export the following callback functions:
handle_call(Msg, {From, Tag}, State) should return
{reply, Reply, State} | {reply, Reply, State, Timeout} | {noreply,
State} | {noreply, State, Timeout} | {stop, Reason, Reply, State}
handle_cast(Msg, State) should return
{noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}
If the above are not exported but called, the wx_object process will crash. ๐ The user module can also export:
Info is message e.g. {'EXIT', P, R}, {nodedown, N}, ...
handle_info(Info, State) should return , ...
{noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}
If a message is sent to the wx_object process when handle_info is not exported, the message will be dropped and ignored. ๐
When stop is returned in one of the functions above with Reason = normal | shutdown | Term, terminate(State) is called. It lets the user module clean up, it is always called when server terminates or when wx_object() in the driver is deleted. If the Parent process terminates the Module:terminate/2 function is called. ๐ซถ
terminate(Reason, State)
Example:
-module(myDialog).
-export([new/2, show/1, destroy/1]). %% API
-export([init/1, handle_call/3, handle_event/2,
handle_info/2, code_change/3, terminate/2]).
new/2, showModal/1, destroy/1]). %% Callbacks
%% Client API
new(Parent, Msg) ->
wx_object:start(?MODULE, [Parent,Id], []).
show(Dialog) ->
wx_object:call(Dialog, show_modal).
destroy(Dialog) ->
wx_object:call(Dialog, destroy).
%% Server Implementation ala gen_server
init([Parent, Str]) ->
Dialog = wxDialog:new(Parent, 42, "Testing", []),
...
wxDialog:connect(Dialog, command_button_clicked),
{Dialog, MyState}.
handle_call(show, _From, State) ->
wxDialog:show(State#state.win),
{reply, ok, State};
...
handle_event(#wx{}, State) ->
io:format("Users clicked button~n",[]),
{noreply, State};
...
๐ฆ DATA TYPES ๐ฆ
request_id() = term():
server_ref() = wx:wx_object() | atom() | pid():
๐ฅ EXPORTS ๐ฅ
start(Name, Mod, Args, Options) -> wxWindow:wxWindow() | {error, term()}โ Starts a genericwx_objectserver and invokesMod:init(Args)in the new process. โจ- Types:
Name = {local, atom()}Mod = atom()Args = term()Flag = trace | log | {logfile, string()} | statistics | debugOptions = [{timeout, timeout()} | {debug, [Flag]}]
- Types:
start_link(Mod, Args, Options) -> wxWindow:wxWindow() | {error, term()}โ Starts a genericwx_objectserver and invokesMod:init(Args)in the new process. ๐- Types:
Mod = atom()Args = term()Flag = trace | log | {logfile, string()} | statistics | debugOptions = [{timeout, timeout()} | {debug, [Flag]}]
- Types:
start_link(Name, Mod, Args, Options) -> wxWindow:wxWindow() | {error, term()}โ Starts a genericwx_objectserver and invokesMod:init(Args)in the new process. ๐- Types:
Name = {local, atom()}Mod = atom()Args = term()Flag = trace | log | {logfile, string()} | statistics | debugOptions = [{timeout, timeout()} | {debug, [Flag]}]
- Types:
stop(Obj) -> okโ Stops a genericwx_objectserver with reason'normal'. Invokesterminate(Reason,State)in the server. The call waits until the process is terminated. If the process does not exist, an exception is raised. ๐ญ- Types:
Obj = wx:wx_object() | atom() | pid()
- Types:
stop(Obj, Reason, Timeout) -> okโ Stops a genericwx_objectserver with the givenReason. Invokesterminate(Reason,State)in the server. The call waits until the process is terminated. If the call times out, or if the process does not exist, an exception is raised. ๐- Types:
Obj = wx:wx_object() | atom() | pid()Reason = term()Timeout = timeout()
- Types:
call(Obj, Request) -> term()โ Make a call to awx_objectserver. The call waits until it gets a result. Invokeshandle_call(Request, From, State)in the server. ๐- Types:
Obj = wx:wx_object() | atom() | pid()Request = term()
- Types:
call(Obj, Request, Timeout) -> term()โ Make a call to awx_objectserver with a timeout. Invokeshandle_call(Request, From, State)in server. โณ- Types:
Obj = wx:wx_object() | atom() | pid()Request = term()Timeout = integer()
- Types:
send_request(Obj, Request::term()) -> request_id()โ Make ansend_requestto a generic server and return aRequestIdwhich can/should be used withwait_response/[1|2]. Invokeshandle_call(Request, From, State)in server. ๐- Types:
Obj = wx:wx_object() | atom() | pid()
- Types:
wait_response(RequestId::request_id()) -> {reply, Reply::term()} | {error, {term(), server_ref()}}โ Wait infinitely for a reply from a generic server. โพ๏ธwait_response(Key::request_id(), Timeout::timeout()) -> {reply, Reply::term()} | timeout | {error, {term(), server_ref()}}โ Wait'timeout'for a reply from a generic server. โฐcheck_response(Msg::term(), Key::request_id()) -> {reply, Reply::term()} | false | {error, {term(), server_ref()}}โ Check if a received message was a reply to aRequestId. ๐cast(Obj, Request) -> okโ Make a cast to awx_objectserver. Invokeshandle_cast(Request, State)in the server. ๐- Types:
Obj = wx:wx_object() | atom() | pid()Request = term()
- Types:
get_pid(Obj) -> pid()โ Get the pid of the object handle. ๐- Types:
Obj = wx:wx_object() | atom() | pid()
- Types:
set_pid(Obj, Pid::pid()) -> wx:wx_object()โ Sets the controlling process of the object handle. ๐ฎ- Types:
Obj = wx:wx_object() | atom() | pid()
- Types:
reply(X1::{pid(), Tag::term()}, Reply::term()) -> pid()โ Get the pid of the object handle. (yes, same desc again, we don't make the rules ๐ญ)
๐ AUTHORS ๐
<> ๐ซถ
source/version: wx 2.2.2.1; manual: wx_object(3erl); date: not shown in the footer, bestie. that's the whole sign-off, stay iconic ๐
โจ
๐ฆ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 ยท Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms