Advertisement
Guest User

Untitled

a guest
May 25th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. -module('listing1-1').
  2. -export([start/0]).
  3.  
  4. -include_lib("wx/include/wx.hrl").
  5.  
  6. start() ->
  7. _WX = wx:new(),
  8. Frame = wxFrame:new(wx:null(), ?wxID_ANY, "MyFrame", [{size, {300, 300}}]),
  9. Panel = wxPanel:new(Frame),
  10. wxStaticText:new(Panel, ?wxID_ANY, "Pos:", [{pos, {10, 12}}]),
  11. PosCtrl = wxTextCtrl:new(Panel, ?wxID_ANY, [{value,""}, {pos, {40, 10}}]),
  12. wxFrame:connect(Panel, motion),
  13. wxFrame:connect(Frame, close_window),
  14. wxFrame:show(Frame),
  15. loop(Frame, PosCtrl),
  16. wx:destroy().
  17.  
  18. loop(Frame, PosCtrl) ->
  19. receive
  20. #wx{event=#wxClose{type=close_window}} ->
  21. ok; % NOT wxWindow:close(Frame,[]) ;
  22. #wx{event=#wxMouse{type=motion, x=X, y=Y}} ->
  23. wxTextCtrl:setValue(PosCtrl, integer_to_list(X)++", "++integer_to_list(Y)), %% could do better?
  24. loop(Frame, PosCtrl)
  25. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement