Created
December 27, 2019 13:07
-
-
Save maximvl/de4a739b26ab15e88918824731dc5391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(dirtest). | |
-include_lib("wx/include/wx.hrl"). | |
-behaviour(wx_object). | |
-export([start/0, init/1, | |
terminate/2, code_change/3, | |
handle_info/2, handle_call/3, handle_cast/2, handle_event/2]). | |
start() -> wx_object:start_link(?MODULE, [], []). | |
%% Callbacks | |
init(Config) -> | |
wx:new(Config), | |
process_flag(trap_exit, true), | |
Frame = wxFrame:new(wx:null(), ?wxID_ANY, "wxErlang widgets", [{size,{1000,500}}]), | |
List = wxListCtrl:new(Frame), | |
[wxListCtrl:insertItem(List, Id, integer_to_list(Id)) || Id <- lists:seq(1, 200)], | |
wxListCtrl:connect(List, command_list_item_selected, []), | |
wxFrame:show(Frame), | |
{Frame, #{list => List}}. | |
handle_call(Msg, _From, State) -> | |
{reply,ok,State}. | |
handle_cast(Msg, State) -> | |
{noreply,State}. | |
handle_info(Msg, State) -> | |
{noreply,State}. | |
handle_event(#wx{event=#wxList{}}, State) -> | |
#{list := List} = State, | |
wxListCtrl:deleteAllItems(List), | |
[wxListCtrl:insertItem(List, Id, integer_to_list(Id)) || Id <- lists:seq(1, 200)], | |
{noreply, State}. | |
code_change(_, _, State) -> | |
{stop, not_yet_implemented, State}. | |
terminate(_Reason, _State) -> | |
ok. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment