1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Gui: Refactor IptKey; in particular, use SWING and SWT constants where possible; also handle modifers

This commit is contained in:
gnosygnu
2016-12-31 00:36:12 -05:00
parent 5c3e4287f0
commit c3d4f520de
7 changed files with 286 additions and 97 deletions

View File

@@ -241,6 +241,22 @@ public class Gfui_bnd_parser {
Init_itm("mouse.middle", "Middle Click");
Init_itm("mouse.left", "Left Click");
Init_itm("mouse.right", "Right Click");
Init_itm("key.numpad_0", "Numpad 0");
Init_itm("key.numpad_1", "Numpad 1");
Init_itm("key.numpad_2", "Numpad 2");
Init_itm("key.numpad_3", "Numpad 3");
Init_itm("key.numpad_4", "Numpad 4");
Init_itm("key.numpad_5", "Numpad 5");
Init_itm("key.numpad_6", "Numpad 6");
Init_itm("key.numpad_7", "Numpad 7");
Init_itm("key.numpad_8", "Numpad 8");
Init_itm("key.numpad_9", "Numpad 9");
Init_itm("key.numpad_multiply", "Numpad Multiply");
Init_itm("key.numpad_add", "Numpad Add");
Init_itm("key.numpad_subtract", "Numpad Subtract");
Init_itm("key.numpad_decimal", "Numpad Decimal");
Init_itm("key.numpad_divide", "Numpad Divide");
// Init_itm("key.numpad_enter", "Numpad Enter");
return this;
}
private void Init_itm(String gfui, String norm) {Init_itm(Gfui_bnd_tkn.Tid_key, gfui, norm);}

View File

@@ -35,6 +35,7 @@ public class Xog_bnd_mgr implements Gfo_invk {
Add_custom_bnds(); // NOTE: should go after Add_system_bnds in case user overrides any;
Bind_all();
app.Cfg().Sub_many_app(this, Run__show_remap_win);
app.Cfg().Bind_many_app(this
, "xowa.gui.shortcuts.xowa.app.exit-1"
, "xowa.gui.shortcuts.xowa.nav.go_bwd-1"
@@ -369,11 +370,18 @@ public class Xog_bnd_mgr implements Gfo_invk {
this.Bind(Xog_bnd_box_.Tid_browser_info , win.Info_box());
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
String[] flds = gplx.xowa.addons.apps.cfgs.enums.Xoitm_gui_binding.To_ary(m.ReadStr("v"));
int box = Xog_bnd_box_.Xto_sys_int(flds[0]);
String key = String_.Replace(k, "xowa.gui.shortcuts.", "");
Xog_bnd_itm bnd = app.Gui_mgr().Bnd_mgr().Get_or_null(key);
Set(bnd, box, IptArg_.parse(flds[1]));
if (String_.Eq(k, Run__show_remap_win)) {
Xog_bnd_win win = new Xog_bnd_win();
win.Show(app, app.Gui_mgr().Kit(), app.Gui_mgr().Browser_win().Win_box(), this.Bnd_parser(), "", "");
}
else {
String[] flds = gplx.xowa.addons.apps.cfgs.enums.Xoitm_gui_binding.To_ary(m.ReadStr("v"));
int box = Xog_bnd_box_.Xto_sys_int(flds[0]);
String key = String_.Replace(k, "xowa.gui.shortcuts.", "");
Xog_bnd_itm bnd = app.Gui_mgr().Bnd_mgr().Get_or_null(key);
Set(bnd, box, IptArg_.parse(flds[1]));
}
return this;
}
private static final String Run__show_remap_win = "xowa.gui.shortcuts.show_remap_win";
}

View File

@@ -17,14 +17,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.guis.bnds; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
import gplx.gfui.*; import gplx.gfui.draws.*; import gplx.gfui.ipts.*; import gplx.gfui.kits.core.*; import gplx.gfui.envs.*; import gplx.gfui.controls.windows.*; import gplx.gfui.controls.elems.*; import gplx.gfui.controls.standards.*;
import gplx.xowa.guis.cbks.*;
public class Xog_bnd_win implements Gfo_invk {
private GfuiWin win;
private GfuiTextBox shortcut_txt, binding_txt, keycode_txt;
private GfuiBtn ok_btn, cxl_btn;
private Gfui_bnd_parser bnd_parser;
public void Show(Gfui_kit kit, GfuiWin owner_win, Gfui_bnd_parser bnd_parser, String shortcut_text, String binding_text) {
private Xoa_app app;
public void Show(Xoa_app app, Gfui_kit kit, GfuiWin owner_win, Gfui_bnd_parser bnd_parser, String shortcut_text, String binding_text) {
this.app = app;
// create controls
this.win = kit.New_win_utl("shortcut_win", owner_win); win.BackColor_(ColorAdp_.White).Size_(200, 120);
this.win = kit.New_win_utl("shortcut_win", owner_win); win.BackColor_(ColorAdp_.White).Size_(240, 140);
this.bnd_parser = bnd_parser;
GfuiLbl shortcut_lbl = Make_lbl(kit, win, "shortcut_lbl" , "Shortcut:");
GfuiLbl binding_lbl = Make_lbl(kit, win, "binding_lbl" , "Binding:");
@@ -75,11 +79,16 @@ public class Xog_bnd_win implements Gfo_invk {
elem_2.Y_(y);
elem_2.X_(elem_1.X_max());
}
private final Xog_cbk_trg cbk_trg = Xog_cbk_trg.New(gplx.xowa.addons.apps.cfgs.specials.edits.pages.Xocfg_edit_special.Prototype.Special__meta().Ttl_bry());
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_when_key_down)) When_key_down(m);
else if (ctx.Match(k, Invk_when_key_press)) When_key_up(m);
else if (ctx.Match(k, Invk_when_key_up)) When_key_up(m);
else if (ctx.Match(k, Invk_when_ok)) {win.Close();}
else if (ctx.Match(k, Invk_when_ok)) {
app.Gui__cbk_mgr().Send_json(cbk_trg, "xo.cfg_edit.gui_binding__remap_recv", gplx.core.gfobjs.Gfobj_nde.New().Add_str("bnd", binding_txt.Text()));
win.Close();
}
else if (ctx.Match(k, Invk_when_cxl)) {win.Close();}
else return Gfo_invk_.Rv_unhandled;
return this;