From b8339d7edf63c8745be4be092e63f46bc4e63b91 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Wed, 28 Sep 2016 13:13:20 +0200 Subject: wx: add wxWindowDragAcceptFiles Enable window to handle drop file events. --- lib/wx/examples/demo/demo.erl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'lib/wx/examples/demo/demo.erl') 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. -- cgit v1.2.3