Thanks for the hint, Alex. I have now managed to extend the "contextmenu"
event handler to make the menu popup next to the mouse cursor:

htmlArea.addListener("contextmenu", function(e)
{
  var mouseData = e.getData();
  var location = htmlArea.getContainerLocation();
  this.popupMenu.setOffsetLeft(mouseData.relX);
  this.popupMenu.setOffsetTop(-location.bottom + mouseData.y);
  this.popupMenu.open();
}, this);

Looks a bit weird, but it works. (BTW: Why doesn't the HtmlArea handle the
positioning by itself?) 

Now I have another problem: Once the popup menu is opened, how do I close it
if I don't want to click on one of its options? Clicking outside the menu's
client area doesn't work, pressing ESC works sometimes but mostly it doesn't
(http://tinyurl.com/27km6dj). And since the HtmlArea doesn't fire any
"keypress" or "click" event I can't even handle this task "manually".

Cheers,

  Norbert
 

Alexander Steitz wrote:
> 
> Hi Norbert,
> 
>> I'm currently struggling with context menus in the HtmlArea widget.
>> When performing a right click within the text area of the widget I would
>> like it to display a popup menu at the mouse cursor position, however, it
>> refuses to do so. With the default settings the menu gets placed at the
>> bottom-
>> left  corner of the widget (cf.  http://tinyurl.com/394ytbx
>> http://tinyurl.com/394ytbx ). I have tried different placement
>> settings, including the menu's openToMouse method, but - nada.
>> 
>> Any hints or instructions are appreciated.
> The contextmenu can easily be positioned using the data of the
> "contextmenu" event which is fired by the HtmlArea. This event is
> delivering the relative (= to the HtmlArea) and the absolute X and Y
> coords. Just check the given data of the event.
> 
> --snip--
> htmlArea.addListener("contextmenu", function(e)
> {
>   this.debug(this.popupMenu.getPlaceMethod());
>   this.popupMenu.open();
>   var positions = e.getData();
> }, this);
> --snip-- 
> 
> I have to admit that the documentation (for the UI-level component) for
> this event and the data has to be completed (I already added it to the
> current branch and the trunk).
> 
> The low-level component is already documented correctly.
> -> http://demo.qooxdoo.org/current/apiviewer/#qx.bom.htmlarea.HtmlArea
> 
> Regards,
>   Alex
> 
> ------------------------------------------------------------------------------
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
> 
> 

-- 
View this message in context: 
http://qooxdoo.678.n2.nabble.com/HtmlArea-and-context-menus-tp5647587p5650451.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to