Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module('listing1-1').
- -export([start/0]).
- -include_lib("wx/include/wx.hrl").
- start() ->
- _WX = wx:new(),
- Frame = wxFrame:new(wx:null(), ?wxID_ANY, "MyFrame", [{size, {300, 300}}]),
- Panel = wxPanel:new(Frame),
- wxStaticText:new(Panel, ?wxID_ANY, "Pos:", [{pos, {10, 12}}]),
- PosCtrl = wxTextCtrl:new(Panel, ?wxID_ANY, [{value,""}, {pos, {40, 10}}]),
- wxFrame:connect(Panel, motion),
- wxFrame:connect(Frame, close_window),
- wxFrame:show(Frame),
- loop(Frame, PosCtrl),
- wx:destroy().
- loop(Frame, PosCtrl) ->
- receive
- #wx{event=#wxClose{type=close_window}} ->
- ok; % NOT wxWindow:close(Frame,[]) ;
- #wx{event=#wxMouse{type=motion, x=X, y=Y}} ->
- wxTextCtrl:setValue(PosCtrl, integer_to_list(X)++", "++integer_to_list(Y)), %% could do better?
- loop(Frame, PosCtrl)
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement