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