Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I want to write a script which detects the mouse hovering over a cell (or if not possible, triggered by a menu as described in "Google Developers: Apps Script: Custom Menus in Google Apps".

This script would display a popup, or fill a special cell with an image. This image URL would be built using the content of the cell.

Any idea?

share|improve this question
    
Have you made some progress in the meantime? –  Jacob Jan Tuinstra Feb 9 '13 at 23:01
2  
Hovering is definitely a non-starter; one cannot directly interact with DOM of a Google service page from within a Spreadsheet or Apps script environment. –  Normal Human Jul 24 at 18:10

1 Answer 1

Short answer

Use 1) the HTML Service of Google Apps Script or 2) update a cell formula with the IMAGE() fuction, any of them triggered by a Custom Menu as Google Docs editors doesn't include a mouse hovering event.

Explanation

Google spreadsheets and Google Apps Script (GAS) have had a lot of changes since the question was posted. One of them is that the GAS documentation was moved to http://developers.google.com/apps-script.

AFAIK GAS doesn't have a mouse hovering trigger event but there are several alternatives like custom menus, simple triggers and installable triggers.

By the other side, filling a cell with an image can be done with a built-in function, IMAGE(), which have four image sizing modes.

GAS an IMAGE() could be used together to insert an image inside a cell and this could be triggered by a custom menu.

Alternative

Use Custom Menus instead of mouse hovering to trigger one of the next actions:

  1. Update a cell formula with the IMAGE() function.
  2. Use a method of the UI Class like:

    1. showModalDialog
    2. showSideBar

In both cases the image should be part of an htmlOutput object of the HTML Service.

Remarks

About Notes and Comments

Built-in notes or comments are displayed by mouse hovering. They could include the image URL. Notes will display it as text while a comment as a link.

Once the user is in the Google Sheets spreadsheet editor.

  • To insert a note click Insert > Note
  • To insert a comment click Insert > Comment

About other UI resources

  • toast, alert and prompt Google Apps Script methods shows plain text messages.

HTML Service: Restrictions

From [3]:

To protect users from being served malicious HTML or JavaScript, Apps Script uses a security sandbox to sandbox HTML-service web apps or custom user interfaces for Google Docs, Sheets, and Forms. (The HTML service does not use a sandbox in other situations, like generating the body of an email.) The sandbox imposes limitations on client-side code.

References

share|improve this answer
1  
This IMAGE function is really part of what I wanted, thanks ! –  Michel Daviot Jul 24 at 16:32
    
Any idea how I can launch a javascript when I click or hover over a cell ? And display the image over the cells rather than in a cell (which has quite small height) ? –  Michel Daviot Jul 24 at 16:33
1  
Google Apps Script is the Google version of JavaScript to extend several Google Apps. Unfortunately it doesn't include mouse hovering or mouse gestures to trigger custom functions. The possibilities to extend Google Apps are limited due to security concerns. For further details see developers.google.com/apps-script/guides/html/restrictions –  Rubén Jul 24 at 16:40
    
Forget to mention @MichelDaviot –  Rubén Jul 24 at 16:46
1  
@MichelDaviot I updated the question. Hopefully now is more clear and helpful. –  Rubén Jul 25 at 20:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.