aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/examples/demo
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2016-09-28 13:13:20 +0200
committerDan Gudmundsson <[email protected]>2016-09-29 09:47:38 +0200
commitb8339d7edf63c8745be4be092e63f46bc4e63b91 (patch)
tree5f160a5782ff7813865851d1cc33316888c0f54c /lib/wx/examples/demo
parentb271012d04897f788866760c1dea7d51b1b44a4d (diff)
downloadotp-b8339d7edf63c8745be4be092e63f46bc4e63b91.tar.gz
otp-b8339d7edf63c8745be4be092e63f46bc4e63b91.tar.bz2
otp-b8339d7edf63c8745be4be092e63f46bc4e63b91.zip
wx: add wxWindowDragAcceptFiles
Enable window to handle drop file events.
Diffstat (limited to 'lib/wx/examples/demo')
-rw-r--r--lib/wx/examples/demo/demo.erl19
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.