I was listening to the lullabot podcast interview with Konstantine
Kaefer
who was talking about his Summer of Code work. During his
discussion
of a module he referred to as "Live Editing", where text could be
clicked
and edited in place like on Flickr, He ran into a technical hurdle on
being able to edit button text by clicking on it. I had an idea of a
possible work around for this.
My general idea is to use javascript to create custom right-click menus
so
instead of the browser right click menus of copy/paste and all, an
administrator would see options like "edit" and "delete" or whatever
else is possible and applies to the object that was right clicked. So in Konstantine's problem
the
solution would be to have the administrator just right-click on the
button
and they would then have the option to "edit" which solves the problem
of
clicking causing a submit instead of an edit. I have be researching
this
possibility and have found some examples of cross-browser support for
these types of menus and some examples of how to add right-click events
to
buttons and things.
This page shows the right click menu concept and it works in everything except opera:
http://www.javascriptkit.com/dhtmltutors/domevent4.shtml
Does anyone else think this is an idea worth pursuing??
Feedback?
-Steve

Comments
great idea
this could be a great add on module - context sensitive pop ups. As with all JS - not strictly necessary for navigation and use, but more convenient than a bunch of page refreshes.
Perhaps a hook_pop_up_menu or something so that modules could add to the menu. If nothing else, perhaps you could grab help text and put it in the menu.
Food for thought.
-M
Sorry about the misspelling
Sorry about the misspelling there Konstantin.
I like the hook_pop_up_menu idea that would make it really versatile.
I am brand new to this drupal development thing, what would be the next course of action? Just start trying to write the code?
-Steve
code, code, code
That's your best bet. Your best tools in that are the docs at http://api-drupal.pajunas.com/ and the #drupal channel on freenode.net.
I would suggest writing your module for Drupal 5.0, unless you have a compelling reason to write for drupal 4.7. Drupal 5 ships with JQuery built in. Hopefully, this framework would make your job easier. There might even be a pop up menu plugin for JQuery already. Certainly worth checking the JQuery.com site to see.
Good luck!
-M
I'm Konstantin without the e
I'm Konstantin without the e ;-)
I am not a big fan of the
I am not a big fan of the way JS custom rightclick menus interfere with the browsers own menus ;)
Could the regular edit link not just popup when hovering over the button?
Yeah I looked at the dbl
Yeah I looked at the dbl click module, but it still has the same problem of not being able to edit a button. I am trying for an inplace editing/deleting/(add?)/(un)publish sort of thing.
Is it possible to just append to the user's right click menu??? .... guess i'll do some research ...
I like grugnog's idea as an alternative....kind of like a tool-tip type of thing, but with admin actions inside..
-Steve
DblClick Module
Have you checked out DblClick Module? It does a lot of what you're saying... including offering hook_dblclick() for other modules.
I thought about pursuing the context-menu option for this, but the real problem is that there's no hook into the l() function, so you can't append extra handlers to the links on the page depending on the user's permissions (to edit, delete, etc). I suppose you could do an ajax callback with the link as the argument so that you could check permissions and display the appropriate stuff in the context menu. But that would be relatively slow and cause a full Drupal bootstrap each time, so you probably wouldn't want to give many users access to the context menus.
Also I would assume that lots of users would get frustrated by not being able to get their "normal" right-click context menu and be able to open links in a separate tab/window, bookmark links, etc...
It sure would be nice if there were a way to have JS actually append stuff to the browser's built-in context menus.
Anyway, the way dblclick.module works is that it simply adds some GET arguments to the URL when you double click on an internal (Drupal) link. It also has handlers for shift-dblclick, opt-dblclick, and opt-shift-dblclick, so you really have a lot of options. Then the module uses hook_init() to check for ?dblclick=true and hands off the arguments to the modules implementing hook_dblclick().
-= Jeff Robbins | Lullabot | Drupalize.me =-
doubleclick is not very 'safe' either
like the rightclick menu, doubleclick is also handled by the window manager, some systems (or configurations) set the doubleclick to open links e.g. in a new tab.
About the problem of the hook for t(): I once created a simple PO 'translation' wich added the changed the string
foointofoo <a href="/admin/locale/string/search/foo" class="edit po-string">e</a>. That po should then be calles something like nl_with_edit.po and be imported as a language wich is enabled. the admin of the site should have that language as default.With a tiny hack to locale.module to allow GET too (by default /admin/locale/string/search/foo wont bring a search for "foo") you have basically what you need.
This, off course works only once: the purpose was to allow my user to edit the strings into what they thought to be the correct string. After they went trough the site, and cahnge most of the strings into what they though was the correct string, that language would be set as the default.
http://www.webschuur.com | http://bler.webschuur.com
bad idea: rightclick is handled by the desktop
... and not by the website. Many browsers don't even support the rightclick events. Some desktop environments (osX) don't even know the rightclick!
If you depend on a rightclick, without a proper way around it, you bring down usability AND accessability.
I think its a far better idea to look at using DHTML and Js for more obvious tasks first, such as inline editing, or better UI feedback events. But even before that, without any Js and Ajax there aer MANY usability improvements to be made.
So if you aer really concerned about usability, or eager to solve some of the issues in Drupal, I suggest you fiest look at solving them at the lowest layer. If you say that you want to change interface elements such as 'buttons', I suggest you start off with an actual place to do so. There is no proper place, besides locales, where you can change things like button texts. and even the locale interface can be improved a lot, without even touching JS!
No need to dive head-first into javascript-rightclick-event-handling, if there is not even a proper, central way to change the interface strings!
http://www.webschuur.com | http://bler.webschuur.com