Switch to accelerator table hotkeys
This commit is contained in:
+20
-30
@@ -43,6 +43,10 @@
|
||||
-type labeled() :: {Label :: #w{}, Control :: #w{}}.
|
||||
|
||||
|
||||
-define(openEXPRESS, 101).
|
||||
-define(openFWEAVER, 102).
|
||||
|
||||
|
||||
|
||||
%%% Interface functions
|
||||
|
||||
@@ -202,8 +206,14 @@ init(Prefs) ->
|
||||
|
||||
ok = gd_v:safe_size(Frame, Prefs),
|
||||
|
||||
HK_Express = wxAcceleratorEntry:new([{flags, ?wxACCEL_CTRL}, {keyCode, $E}, {cmd, ?openEXPRESS}]),
|
||||
HK_FWeaver = wxAcceleratorEntry:new([{flags, ?wxACCEL_CTRL}, {keyCode, $F}, {cmd, ?openFWEAVER}]),
|
||||
Entries = [HK_Express, HK_FWeaver],
|
||||
Hotkeys = wxAcceleratorTable:new(length(Entries), Entries),
|
||||
ok = wxFrame:setAcceleratorTable(Frame, Hotkeys),
|
||||
ok = lists:foreach(fun wxAcceleratorEntry:destroy/1, Entries),
|
||||
ok = wxFrame:connect(Frame, command_menu_selected),
|
||||
ok = wxFrame:connect(Frame, command_button_clicked),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
ok = wxFrame:connect(Frame, close_window),
|
||||
true = wxFrame:show(Frame),
|
||||
ok = wxListBox:connect(Picker, command_listbox_selected),
|
||||
@@ -312,15 +322,13 @@ handle_event(#wx{event = #wxCommand{type = command_listbox_selected,
|
||||
State) ->
|
||||
NewState = do_selection(Selected, State),
|
||||
{noreply, NewState};
|
||||
handle_event(#wx{event = Event = #wxKey{keyCode = Code}}, State = #s{frame = Frame}) ->
|
||||
handle_event(#wx{event = #wxCommand{type = command_menu_selected}, id = ID}, State) ->
|
||||
NewState =
|
||||
case Code of
|
||||
69 -> express(State); % 'E'
|
||||
70 -> fateweaver(State); % 'F'
|
||||
case ID of
|
||||
?openEXPRESS -> express(State);
|
||||
?openFWEAVER -> fateweaver(State);
|
||||
_ ->
|
||||
ok = tell(info, "Code: ~p", [Code]),
|
||||
ok = tell(info, "Frame ID: ~p", [wxFrame:getId(Frame)]),
|
||||
ok = tell(info, "Event: ~p", [Event]),
|
||||
ok = tell(error, "This should never be able to happen."),
|
||||
State
|
||||
end,
|
||||
{noreply, NewState};
|
||||
@@ -394,7 +402,6 @@ express(State) ->
|
||||
|
||||
|
||||
set_node(State = #s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Set Node")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
|
||||
@@ -446,7 +453,6 @@ set_node(State = #s{frame = Frame, j = J}) ->
|
||||
ok
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
State.
|
||||
|
||||
add_node2(Address, PortCtrls) ->
|
||||
@@ -479,7 +485,6 @@ s_to_i(S) ->
|
||||
|
||||
|
||||
make_key(State = #s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("New Key")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
|
||||
@@ -549,12 +554,10 @@ make_key(State = #s{frame = Frame, j = J}) ->
|
||||
ok
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
State.
|
||||
|
||||
|
||||
recover_key(State = #s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Mnemonic")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
MnemSz = wxStaticBoxSizer:new(?wxVERTICAL, Dialog, [{label, J("Recovery Phrase")}]),
|
||||
@@ -580,7 +583,6 @@ recover_key(State = #s{frame = Frame, j = J}) ->
|
||||
ok
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
State.
|
||||
|
||||
|
||||
@@ -593,7 +595,6 @@ show_mnemonic(State = #s{picker = Picker}) ->
|
||||
end.
|
||||
|
||||
show_mnemonic(Selected, State = #s{frame = Frame, j = J, accounts = Accounts}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
#poa{id = ID} = lists:nth(Selected, Accounts),
|
||||
{ok, Mnemonic} = gd_con:mnemonic(ID),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Mnemonic")),
|
||||
@@ -619,7 +620,6 @@ show_mnemonic(Selected, State = #s{frame = Frame, j = J, accounts = Accounts}) -
|
||||
?wxID_OK -> gd_lib:copy_to_clipboard(Mnemonic)
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
State.
|
||||
|
||||
|
||||
@@ -654,7 +654,6 @@ drop_key(State = #s{picker = Picker}) ->
|
||||
end.
|
||||
|
||||
drop_key(Selected, State = #s{frame = Frame, j = J, accounts = Accounts, prefs = Prefs}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
#poa{id = ID, name = Name} = lists:nth(Selected, Accounts),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("New Key"), [{size, {500, 150}}]),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
@@ -683,7 +682,6 @@ drop_key(Selected, State = #s{frame = Frame, j = J, accounts = Accounts, prefs =
|
||||
Prefs
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
ok = wxFrame:connect(Frame, char_hook),
|
||||
State#s{prefs = NewPrefs}.
|
||||
|
||||
|
||||
@@ -853,7 +851,6 @@ do_chain(ChainID, #node{ip = IP}, #s{buttons = Buttons}) ->
|
||||
|
||||
|
||||
do_ask_password(#s{frame = Frame, prefs = Prefs, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Password")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
Label = J("Password (leave blank for no password)"),
|
||||
@@ -885,8 +882,7 @@ do_ask_password(#s{frame = Frame, prefs = Prefs, j = J}) ->
|
||||
?wxID_CANCEL ->
|
||||
gd_con:open_wallet(Path, none)
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
wxFrame:connect(Frame, char_hook).
|
||||
wxDialog:destroy(Dialog).
|
||||
|
||||
do_grids_mess_sig(_, #s{accounts = []}) ->
|
||||
ok;
|
||||
@@ -915,7 +911,6 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
"public_id" := ID,
|
||||
"payload" := Message},
|
||||
#s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Message Signature Request")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
Instruction =
|
||||
@@ -951,15 +946,13 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
?wxID_OK -> gd_con:sign_mess(Request);
|
||||
?wxID_CANCEL -> ok
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
wxFrame:connect(Frame, char_hook);
|
||||
wxDialog:destroy(Dialog);
|
||||
do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
"type" := "binary",
|
||||
"url" := URL,
|
||||
"public_id" := ID,
|
||||
"payload" := Base64},
|
||||
#s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Binary Data Signature Request")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
Instruction =
|
||||
@@ -995,8 +988,7 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
?wxID_OK -> gd_con:sign_binary(Request);
|
||||
?wxID_CANCEL -> ok
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
wxFrame:connect(Frame, char_hook);
|
||||
wxDialog:destroy(Dialog);
|
||||
do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
"type" := "tx",
|
||||
"url" := URL,
|
||||
@@ -1005,7 +997,6 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
"public_id" := ID,
|
||||
"payload" := CallData},
|
||||
#s{frame = Frame, j = J}) ->
|
||||
true = wxFrame:disconnect(Frame, char_hook),
|
||||
Dialog = wxDialog:new(Frame, ?wxID_ANY, J("Message Signature Request")),
|
||||
Sizer = wxBoxSizer:new(?wxVERTICAL),
|
||||
|
||||
@@ -1053,7 +1044,6 @@ do_grids_mess_sig2(Request = #{"grids" := 1,
|
||||
?wxID_OK -> gd_con:sign_tx(Request);
|
||||
?wxID_CANCEL -> ok
|
||||
end,
|
||||
ok = wxDialog:destroy(Dialog),
|
||||
wxFrame:connect(Frame, char_hook);
|
||||
wxDialog:destroy(Dialog);
|
||||
do_grids_mess_sig2(BadRequest, _) ->
|
||||
tell("Bad request: ~tp", [BadRequest]).
|
||||
|
||||
Reference in New Issue
Block a user