# HG changeset patch # User Atul Varma # Date 1210363150 25200 # Node ID 21f5e1dc0a4cf1d90b784e6b320aa6003e19f4a6 # Parent 4f22928c7a2c40b940212cff6f4615a0887dad34 text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any. diff -r 4f22928c7a2c -r 21f5e1dc0a4c enso_pyxpcom.py --- a/enso_pyxpcom.py Thu May 08 13:00:26 2008 -0700 +++ b/enso_pyxpcom.py Fri May 09 12:59:10 2008 -0700 @@ -22,7 +22,9 @@ Application = getFuelApplication() document = Application.activeWindow.activeTab.document - mediator = cc["@mozilla.org/appshell/window-mediator;1"].getService(ci.nsIWindowMediator) + mediator = cc["@mozilla.org/appshell/window-mediator;1"].getService( + ci.nsIWindowMediator + ) window = mediator.getMostRecentWindow("navigator:browser") return window.document.commandDispatcher @@ -46,12 +48,16 @@ end = dispatcher.focusedElement.selectionEnd if start != end: text = dispatcher.focusedElement.value[start:end] + else: + text = dispatcher.focusedElement.value elif dispatcher.focusedWindow: sel = dispatcher.focusedWindow.getSelection() if sel.rangeCount >= 1: text = sel.toString() - return {"text" : text} + return {"text" : text, + "dom.element" : dispatcher.focusedElement, + "dom.window" : dispatcher.focusedWindow} def installFirefoxSelectionHook(): from enso.platform.osx import selection