diff options
Diffstat (limited to 'lib/wx/examples')
-rw-r--r-- | lib/wx/examples/demo/demo.erl | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/wx/examples/demo/demo.erl b/lib/wx/examples/demo/demo.erl index 99c28b3177..8b7412017a 100644 --- a/lib/wx/examples/demo/demo.erl +++ b/lib/wx/examples/demo/demo.erl @@ -60,11 +60,15 @@ start_link() -> start_link(Debug) -> wx_object:start_link(?MODULE, Debug, []). +format(#state{log=Log}, Str, Args) -> + wxTextCtrl:appendText(Log, io_lib:format(Str, Args)), + ok; format(Config,Str,Args) -> Log = proplists:get_value(log, Config), wxTextCtrl:appendText(Log, io_lib:format(Str, Args)), ok. + -define(DEBUG_NONE, 101). -define(DEBUG_VERBOSE, 102). -define(DEBUG_TRACE, 103). @@ -97,7 +101,11 @@ init(Options) -> wxFrame:connect(Frame, close_window), _SB = wxFrame:createStatusBar(Frame,[]), - + + %% Setup on toplevel because stc seems to steal this on linux + wxFrame:dragAcceptFiles(Frame, true), + wxFrame:connect(Frame, drop_files), + %% T Uppersplitter %% O Left | Right %% P Widgets|Code | Demo @@ -201,15 +209,15 @@ handle_info({'EXIT',_, shutdown}, State) -> handle_info({'EXIT',_, normal}, State) -> {noreply,State}; handle_info(Msg, State) -> - io:format("Got Info ~p~n",[Msg]), + format(State, "Got Info ~p~n",[Msg]), {noreply,State}. handle_call(Msg, _From, State) -> - io:format("Got Call ~p~n",[Msg]), + format(State, "Got Call ~p~n",[Msg]), {reply,ok,State}. handle_cast(Msg, State) -> - io:format("Got cast ~p~n",[Msg]), + format(State, "Got cast ~p~n",[Msg]), {noreply,State}. %% Async Events are handled in handle_event as in handle_info @@ -286,7 +294,7 @@ handle_event(#wx{event=#wxClose{}}, State = #state{win=Frame}) -> ok = wxFrame:setStatusText(Frame, "Closing...",[]), {stop, normal, State}; handle_event(Ev,State) -> - io:format("~p Got event ~p ~n",[?MODULE, Ev]), + format(State, "~p Got event ~p ~n",[?MODULE, Ev]), {noreply, State}. code_change(_, _, State) -> @@ -364,6 +372,7 @@ code_area(Parent) -> ?stc:setVisiblePolicy(Ed, Policy, 3), %% ?stc:connect(Ed, stc_doubleclick), + %% ?stc:connect(Ed, std_do_drop, fun(Ev, Obj) -> io:format("Ev ~p ~p~n",[Ev,Obj]) end), ?stc:setReadOnly(Ed, true), Ed. |