Hi lostinthesound
Shortcut-keys + a dialog to help you customise them are found:
(menu
):Tools
→Customise
→Keyboard
You will first need to create a macro for the action that you want before what follows below. Part of that is easy (“highlight + copy the word into the Clipboard”) but I’m hazy on the external features of the action (“paste into the Dictionary software search bar, search for it, copy the result”) (I no longer use a Mac). Nevertheless, I’m going to assume that you have called the script “dictionaryIntegration”. See bottom for the beginnings of such a script.
The following is drawn from the Writer help using 5.0.0.5:
Step-by-step:
- (
menu
):Tools
→Customise
→Keyboard
- In the
Category
list box, scroll down and open the “LibreOffice Macros” entry.
- Click to get to where you have stored your script.
(this can easily be the most difficult part!)
(see below)
- Open any scripting language entry to see the available modules + select the “dictionaryIntegration” module.
- In the
Function
list box you will now see a list of all functions in that module. Select the “dictionaryIntegration” function.
- Click the option button for
LibreOffice
or Writer
(this sets the scope of the action)
(the options will change according to which applications are currently open).
- In the
Shortcut Keys
list box, select a key combination that you want to use and click Modify
(that key combo now appears within Keys
next to your script)
- Click on
OK
Errata:
- The 5.0.0.5 help says to look in the
Category
list box, open the LibreOffice Macros
entry & look for:-
LibreOffice Macros : LibreOffice installation share directory
(available for all)
or
My Macros : LibreOffice user directory
(available only for the user)
I do not have any universal macros (that I know about) but also do not have the above sections. Instead, I have:-
user : (containing my user-macros)
share : (macros that I did not add)
- 5.0.0.5 has a
Function
list-box; the Help calls it a Commands
list-box
Notes:
- Scripts are often composed of multiple sub-routines. Top-level functions that make use of the same sub-routines are collected together into ‘modules’.
Workaround:
There is a simple workaround, as detailed at this mac forum post:-
- Select word
- Right-click selected word
- (from the context menu) choose
Synonyms
- (from the sub-menu) choose
Thesaurus…
- (a pop-up dialog gives options to select):
Macro Script:
I’ve written a script that you can use. However, there are lines at the bottom that need to be changed (at this moment it just calls a message-box with the text of the highlighted word(s)). Info on Shell().
dictionaryIntegration.odt (contains just the macros)
Sub dictionaryIntegration()
rem ----------------------------------------------------------------------
rem macro for MacOS use with Dictionary.app
''
rem define variables
dim doc as object
dim cursor as object
dim selection as object
dim selections as object
dim word_to_lookup as string
dim count%, cr$, lf$, ht$, i%
cr = chr( 13 )
lf = chr( 10 )
ht = chr( 9 )
rem ----------------------------------------------------------------------
'' prog note: ThisComponent.getCurrentSelection() (or)
'' ThisComponent.CurrentController.getTransferable()
'' prog note: only one object at a time can contain transferable content
'' prog note: it is possible to have multiple non-contiguous selections,
'' some of which may be empty. We choose the first, only.
doc = ThisComponent
'' sanity checks 1
If IsNull( doc ) Then
MsgBox "'ThisComponent' is Null." + lf + "Fatal error, cannot continue." + lf + lf + "Exiting this function."
Exit Sub
End If
selections = doc.getCurrentSelection()
'' sanity checks 2
If IsNull( selections ) Then
MsgBox "No current Controller." + lf + "Are you working in headless mode?" + lf + lf + "Exiting this function."
Exit Sub
End If
'' sanity checks 3
If selections.getCount() = 0 Then
MsgBox "Congratulations!" + lf + "You are suffering the impossible 'this should never happen' error." + lf + lf + "Exiting this function."
Exit Sub
End If
'' choose the first selection (others silently discarded)
selection = selections.getByIndex( 0 )
'' sanity checks 4
'' does start-selection match end-selection? (empty selection range)
cursor = selection.getText().CreateTextCursorByRange( selection )
If cursor.IsCollapsed() Then
MsgBox "No text selection" + lf + "At least one word must be selected." + lf + lf + "Exiting this function."
Exit Sub
End If
'' count = selections.getCount()
'' For i = 0 To count - 1
'' selection = selections.getByIndex( count )
'' MsgBox selection.getString()
'' Next
word_to_lookup = selection.getString()
'' word_to_lookup = retStrfromTxtClip( doc.getTransferable())
rem !!!TO DO!!!
rem remark-out next line + un-remark 2nd line + match your system.
rem (this is a 'remark' line)
'' (this is also a 'remark' line)
MsgBox word_to_lookup
'' Shell("/full/path/to/dictionaryIntegration.script",2,word_to_lookup)
rem ----------------------------------------------------------------------
End Sub '' dictionaryIntegration
If this helps then please tick the answer ()