1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 17:47:59 +01:00

improve menu mode - track open popup count and menubar activation

This commit is contained in:
Doug Kearns
2007-08-27 14:03:00 +00:00
parent b70ee84a0f
commit 06ef7e384d
2 changed files with 45 additions and 12 deletions

View File

@@ -72,14 +72,46 @@ function Events() //{{{
vimperator.setMode(); // trick to reshow the mode in the command line vimperator.setMode(); // trick to reshow the mode in the command line
}, null); }, null);
// Code for keeping track if a popup is currently active //
// XXX: does currently not handle submenus // track if a popup is open or the menubar is active
this.openPopupCount = 0; //
this.menuBarActive = 100;
window.addEventListener("popupshown", function() { vimperator.log(++vimperator.events.openPopupCount); vimperator.addMode(null, vimperator.modes.MENU); }, true); var popup_count = 0;
window.addEventListener("popuphidden", function() { vimperator.log(--vimperator.events.openPopupCount); vimperator.removeMode(null, vimperator.modes.MENU); }, true); var active_menubar = false;
window.addEventListener("DOMMenuBarActive", function() { vimperator.log(++vimperator.events.menuBarActive);vimperator.addMode(null, vimperator.modes.MENU); }, true);
window.addEventListener("DOMMenuBarInactive", function() { vimperator.log(--vimperator.events.menuBarActive); vimperator.removeMode(null, vimperator.modes.MENU); }, true); function enterPopupMode()
{
popup_count++;
vimperator.log("Open popup window count: " + popup_count, 9);
vimperator.addMode(null, vimperator.modes.MENU);
}
function exitPopupMode()
{
popup_count--;
vimperator.log("Open popup window count: " + popup_count, 9);
if (popup_count == 0)
vimperator.removeMode(null, vimperator.modes.MENU);
}
function enterMenuMode()
{
active_menubar = true;
vimperator.log("Menubar is active", 9);
vimperator.addMode(null, vimperator.modes.MENU)
}
function exitMenuMode()
{
active_menubar = false;
vimperator.log("Menubar is inactive", 9);
vimperator.removeMode(null, vimperator.modes.MENU);
}
window.addEventListener("popupshown", enterPopupMode, true);
window.addEventListener("popuphidden", exitPopupMode, true);
window.addEventListener("DOMMenuBarActive", enterMenuMode, true);
window.addEventListener("DOMMenuBarInactive", exitMenuMode, true);
window.document.addEventListener("DOMTitleChanged", function(event) window.document.addEventListener("DOMTitleChanged", function(event)
{ {
@@ -219,10 +251,10 @@ function Events() //{{{
getBrowser().removeProgressListener(this.progressListener); getBrowser().removeProgressListener(this.progressListener);
window.removeEventListener("popupshowing"); window.removeEventListener("popupshowing", enterPopupMode(), true);
window.removeEventListener("popuphidden"); window.removeEventListener("popuphidden", exitPopupMode(), true);
window.removeEventListener("DOMMenuBarActive"); window.removeEventListener("DOMMenuBarActive", enterMenuMode(), true);
window.removeEventListener("DOMMenuBarInactive"); window.removeEventListener("DOMMenuBarInactive", exitMenuMode(), true);
} }
// This method pushes keys into the event queue from vimperator // This method pushes keys into the event queue from vimperator

View File

@@ -64,6 +64,7 @@ const vimperator = (function() //{{{
mode_messages[modes.QUICK_HINT] = "quick"; mode_messages[modes.QUICK_HINT] = "quick";
mode_messages[modes.EXTENDED_HINT] = "extended"; mode_messages[modes.EXTENDED_HINT] = "extended";
mode_messages[modes.ALWAYS_HINT] = "always"; mode_messages[modes.ALWAYS_HINT] = "always";
mode_messages[modes.MENU] = "menu"; // TODO: desirable?
var mode = modes.NORMAL; var mode = modes.NORMAL;
var extended_mode = modes.NONE; var extended_mode = modes.NONE;