diff options
author | Dan Gudmundsson <[email protected]> | 2016-10-05 16:05:08 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2016-10-05 16:05:08 +0200 |
commit | 1de609cb262ff34216dce8fbefdb9a153bdd2c93 (patch) | |
tree | 1d852d320dc26d002263e8fef4eda72e5291b021 /lib/wx/examples | |
parent | 497330a828089b465ac026551edf33fb947ae2f6 (diff) | |
parent | b8339d7edf63c8745be4be092e63f46bc4e63b91 (diff) | |
download | otp-1de609cb262ff34216dce8fbefdb9a153bdd2c93.tar.gz otp-1de609cb262ff34216dce8fbefdb9a153bdd2c93.tar.bz2 otp-1de609cb262ff34216dce8fbefdb9a153bdd2c93.zip |
Merge branch 'dgud/wx/drop-files/OTP-13933' into maint
* dgud/wx/drop-files/OTP-13933:
wx: add wxWindowDragAcceptFiles
wx: Add simple dropfiles support
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. |