diff --git a/css/window.css b/css/window.css index 3693cffb..d009aa5c 100644 --- a/css/window.css +++ b/css/window.css @@ -450,23 +450,23 @@ padding-right: 5px; padding-left: 0; } - body.is_mobile .panel_selector:only-child { + .panel_selector:only-child { display: none; } - body.is_mobile #panel_selector_bar .panel_selector .icon_wrapper { + #panel_selector_bar .panel_selector .icon_wrapper { margin-top: 6px; } - body.is_mobile #mobile_keyboard_menu { + #mobile_keyboard_menu { width: 48px; text-align: center; padding: 6px; position: relative; color: var(--color-accent); } - body.is_mobile #mobile_keyboard_menu:hover { + #mobile_keyboard_menu:hover { color: var(--color-light); } - body.is_mobile #mobile_keyboard_menu.enabled::after { + #mobile_keyboard_menu.enabled::after { content: ""; display: block; position: absolute; @@ -477,6 +477,10 @@ bottom: 2px; right: 19px; } + #status_bar #mobile_keyboard_menu.enabled::after { + right: 4px; + bottom: 9px; + } /*Menu Bar*/ diff --git a/js/interface/interface.js b/js/interface/interface.js index e1316149..b5ebc7aa 100644 --- a/js/interface/interface.js +++ b/js/interface/interface.js @@ -683,7 +683,34 @@ Interface.CustomElements.SelectInput = function(id, data) { this.set = setKey; } +function openTouchKeyboardModifierMenu(node) { + if (Menu.closed_in_this_click == 'mobile_keyboard') return; + let modifiers = ['ctrl', 'shift', 'alt']; + let menu = new Menu('mobile_keyboard', [ + ...modifiers.map(key => { + let name = tl(`keys.${key}`); + if (Interface.status_bar.vue.modifier_keys[key].length) { + name += ' (' + tl(Interface.status_bar.vue.modifier_keys[key].last()) + ')'; + } + return { + name, + icon: Pressing.overrides[key] ? 'check_box' : 'check_box_outline_blank', + click() { + Pressing.overrides[key] = !Pressing.overrides[key] + } + } + }), + '_', + {icon: 'clear_all', name: 'menu.mobile_keyboard.disable_all', condition: () => { + let {length} = [Pressing.overrides.ctrl, Pressing.overrides.shift, Pressing.overrides.alt].filter(key => key); + return length; + }, click() { + Pressing.overrides.ctrl = false; Pressing.overrides.shift = false; Pressing.overrides.alt = false; + }}, + ]) + menu.open(node); +} onVueSetup(function() { Interface.status_bar.vue = new Vue({ @@ -701,7 +728,9 @@ onVueSetup(function() { ctrl: [], shift: [], alt: [] - } + }, + modifiers: Blockbench.isTouch && !Blockbench.isMobile && Pressing.overrides, + keyboard_menu_in_status_bar: Blockbench.isTouch && !Blockbench.isMobile }, methods: { showContextMenu(event) { @@ -756,6 +785,9 @@ onVueSetup(function() { openValidator() { Validator.openDialog(); }, + openKeyboardMenu() { + openTouchKeyboardModifierMenu(this.$refs.mobile_keyboard_menu); + }, toggleSidebar: Interface.toggleSidebar, getIconNode: Blockbench.getIconNode, tl @@ -799,11 +831,15 @@ onVueSetup(function() {