Is there a way to call myFunction() from an image, button, or link within a Google Doc, rather than using the menu? - google-apps-script

I know that in Google Spreadsheets, you can bind a custom script function to the click event of an image, at least manually via the UI.
But in Google Docs, there doesn't seem to be any equivalent functionality. The only options are timers, onOpen() and ilk, and creating a menu item at the top.
Am I missing a way of adding a function launcher somewhere on the doc itself, especially dynamically from a script? I've searched a bunch and pored over the API docs, but I'm not seeing it.

Related

Google Sheets script : Click on menu item

I'd like to have a script that simply clicks on File > Download > PDF of a Google Sheets menu.
To simplify, I first tried to have the script click on "File".
With devtools I could determine that this menu item has id="docs-file-menu" so my function should look like :
document.getElementById('docs-file-menu').click();
But it doesn't work because document is not defined.
While searching for a solution, I understood that Apps scripts cannot interact with the browser, but I'm not quite sure whether that includes the sheets menus items as well?
Is there any way to make a script click on a menu item?
If not possible, is there any other way to make the "download as pdf" window appear?

How to show images on text hover in google docs addon

I am new to google docs Add-ons. I am working on an add-on in which I need to show set of image on text hover like tooltip in html
I did not find a way to implement this after hours of googling. please help.
This is not possible.
The above because the Documents Service of Google Apps Script doesn't include "on hover" event / trigger or something similar
The only way is by using a dialog or sidebar and they can only be launched by clicking on a custom menu or by using google.script.run on a previously opened dialog / sidebar.
References
https://developers.google.com/apps-script/guides/doc
https://developers.google.com/apps-script/guides/triggers
https://developers.google.com/apps-script/guides/dialogs
Related
Show Popup of YouTube video within Google Doc

Can I add a Google Hangouts call to a Google Sheet?

I was wondering if it is possible to create a script in Google Sheets to launch a Google Hangout that calls me, preferably by phone but it could also run a video call to my Google+ account.
I currently know how to create a drawing, create a basic function, and assign the script to the drawing to make a button. Just wondering if there is a script out there for this or if it would be possible.
Essentially, I'm trying to add a "Call tech support" button to a complicated spreadsheet.
Thanks in advance!
The best I was able to do was create a button that opens a dialog that shows a "Start a Hangout" button. You can then click that button to open a Hangout window. There may be a way to embed a Hangout window into the dialog directly, but from what I've read, there are restrictions on spreadsheets that prevent some javascript functionality. Here is the code I used:
Code.gs:
function HangoutButton() {
var html = HtmlService.createHtmlOutputFromFile('HangoutButton').setSandboxMode(HtmlService.SandboxMode.IFRAME);
SpreadsheetApp.getUi().showModalDialog(html, 'Loading Hangout Button ...');
}
HangoutButton.html:
<script src="https://apis.google.com/js/platform.js" async defer></script>
<div class="g-hangout" data-render="createhangout"></div>
Here is a link to my working example (it may ask for you to give it permission). It has a button that I have linked to run the HangoutButton() method provided above.

Google Docs: Catching keyup events

I want to implement a custom autocomplete for google docs.
Therefore I would need to access any kind of text-input events within the document.
Are there any ideas how this could be done with App Scripts?
Google Docs doesn't have the onEdit() or onChange() event available to it.
https://developers.google.com/apps-script/guides/triggers/#available_types_of_triggers
I doubt that what you want is possible.
Inside of HTML, you can watch for a key event. But that would only be inside of a Dialog Box created with HTML, or a Sidebar with HTML.

disable dismiss hyperlink and message on google spreadsheet

When we run any method of Google App Script,a message appears on Google Spreadsheet with dismiss hyperlink.
For Example:
Running Script methodname Dismiss hyperlink
I would like to know if there is any option to disable the message and dismiss hyperlink that appears on Google Spreadsheet when any function is executed at the back ground. In not , please share what alternates are available to hide this out.
It is within a div of class docs-butterbar-container so on your own machine, you could add
.docs-butterbar-container {
display:none;
}
to a user stylesheet.
But if you are hoping to hide it from other others of your sheets/scripts then your likely out of luck, unless you have means of rolling out user stylesheets.
I also wouldn't recommend hiding this. It's useful.