Wednesday, 21. November 2007, 19:12:27
Context Menu mod - 'Open in New Tab AND Search'
What is the code to combine 2 context menu tasks, triggered upon double-click'g a word or highlighting a phrase (NOT a LINK):- Open New Tab AND Search
ie. syntax combining:
Item, MI_IDM_MENU_PAGEBAR_LINK_IN_NEW_PAGE=Open link in new page
WITH...
Item, MI_IDM_SELSEARCH=Hotclick search, 200
Wednesday, 21. November 2007, 21:09:29
You really can't as such, the selection loses focus when you open the new tab and makes the search impossible. Holding Shift will work of course, but that's different. Unless you could write a search itself using a javascript URL, you can't get search to automatically open a new tab.
Sunday, 10. August 2008, 04:39:33 (edited)
To set the record straight: search opening in new or background tab, and not requiring shift keys, was always possible with macros (i.e. sequences of Opera commands); it did not require javascript. There were three cases, covered by two options - each with a drawback:
New-window search macros
requiring "reuse" unchecked, rendered text only, but not obliterating clipboard
either "reuse" setting, any text, but obliterating clipboard
Perfected search: •new page or background •wordset or phrase •works on editable text •button or menu item
The context is that Opera's built-in new-tab searches require two-handed gestures to generate (which is obligatory - they can't be re-assigned), lack any provision for phrase search, and don't work on editable text.
Here's a button you can try: %c BackgroundPhraseSearch Best macros can do, not much wrong with it - only that it obliterates the clipboard; but to some people that sort of thing just doesn't seem good enough. Perfection is attainable - so why not have it?
A couple of academic notes:
- if "reuse current tabs" was unchecked, a search which avoided using Opera functions (which ignore the setting) would automatically open in a new window. And there was no focus issue, because the command was issued in the context where the selection existed. One could use the %t (selected text) variable - and leave the clipboard (%c) untouched.
- unfortunately, %t doesn't work in editable text. If one wanted to search for an editable selection, it was necessary to use Copy, and then %c. This of course obliterates anything which had been in the clipboard.
- if "reuse current tab" was checked, one needed New Page, to prevent the search from opening in the current tab - which creates the focus issue, because the context in which a subsequent command involving %t might be tried is no longer the context in which a selection is defined. So this branch too requires Copy, to get the selection onto the clipboard where it can be cited in any context.
New-window search macros
requiring "reuse" unchecked, rendered text only, but not obliterating clipboard
- Wordset search, new tab: go to page, "g %t"
- Phrase search, new tab: go to page, "g %T"
- Wordset search, background: go to page, "g %t" & minimize page
- Phrase search, background: go to page, "g %T" & minimize page
either "reuse" setting, any text, but obliterating clipboard
- Wordset search, new tab: Copy & new page & go to page, "g %c"
- Phrase search, new tab: Copy & new page & go to page, "g %C"
- Wordset search, background: Copy & new page & go to page, "g %c" & minimize page
- Phrase search, background: Copy & new page & go to page, "g %C" & minimize page
Perfected search: •new page or background •wordset or phrase •works on editable text •button or menu item
The context is that Opera's built-in new-tab searches require two-handed gestures to generate (which is obligatory - they can't be re-assigned), lack any provision for phrase search, and don't work on editable text.
Here's a button you can try: %c BackgroundPhraseSearch Best macros can do, not much wrong with it - only that it obliterates the clipboard; but to some people that sort of thing just doesn't seem good enough. Perfection is attainable - so why not have it?
A couple of academic notes:
- the above button doesn't work on editable text - Copy doesn't happen. A context issue (it works when assigned to a keystroke), which means that the macro form should be assigned elsewhere. But it belongs elsewhere - only put on a button to provide a handy demo.
- macro form is not entirely obsolete: it works in sourceview and Notes - which defy javascript - so worth keeping around.
Monday, 11. August 2008, 08:32:34 (edited)
You're welcome! Alas, there's an error in that, and I'm a little too late to correct the post. In fact Opera searches do honour "reuse=0", and open in a new tab - so there's no gain from using %t. Thus, two of the eight branches are handled by Opera functions.
In passing - a confusing point is that %s in Opera search strings means "selected text", and appears to be exactly the same variable as %t everywhere else (while %s is apparently "file spec of source in cache" in non-search contexts). This is bizarrely inconsistent - why not use %t to mean the same thing everywhere? Oh well...
I had a look, after writing yesterday's post, at what could be done within the confines of the search-dialog / search.ini system. I checked whether %S would give phrase searches, and whether %c could be substituted to allow editable-text sources. Alas, no: deviate from %s and they are dead as doornails: nothing happens. However it is possible to add phrase searches by bracketing %s with quotes - escaped, "%s" becomes %22%s%22. So if anyone's interested they can add a Google phrase search to their hotclick menu (for example) that way. It makes sense, compared to not having phrase search. In a larger view Opera's functions, based on a broken variable, just aren't competitive - but persons unversed in these matters are unlikely to be able to process the proof of that: they will feel like what 's inside the shrinkwrap is of a higher class - even though it malfunctions in front of their eyes.
In passing - a confusing point is that %s in Opera search strings means "selected text", and appears to be exactly the same variable as %t everywhere else (while %s is apparently "file spec of source in cache" in non-search contexts). This is bizarrely inconsistent - why not use %t to mean the same thing everywhere? Oh well...
I had a look, after writing yesterday's post, at what could be done within the confines of the search-dialog / search.ini system. I checked whether %S would give phrase searches, and whether %c could be substituted to allow editable-text sources. Alas, no: deviate from %s and they are dead as doornails: nothing happens. However it is possible to add phrase searches by bracketing %s with quotes - escaped, "%s" becomes %22%s%22. So if anyone's interested they can add a Google phrase search to their hotclick menu (for example) that way. It makes sense, compared to not having phrase search. In a larger view Opera's functions, based on a broken variable, just aren't competitive - but persons unversed in these matters are unlikely to be able to process the proof of that: they will feel like what 's inside the shrinkwrap is of a higher class - even though it malfunctions in front of their eyes.
Forums » Opera Community » General Opera topics » Customizing Opera
