According to the documentation, specifying gs:mouse-released with a third argument of "true" will provide a list of tags whose member's bounding boxes intersect the mouse cursor position. However, this doesn't seem to actually work (see example code below). If the "true" argument is removed, then you will see little red circles where you click. Otherwise nada.
* Using NewLisp v.10.4.4
* Using latest x86 Java from Oracle (jre7, platform 1.7, product 1.7.0_07)
* The "true" flag is not working for other functions -- for instance, there's no feedback
when I set "(gs:set-trace true)" or trace messages either.
* Since I couldn't use gs:set-trace, I added this line above the set-trace net-send call:
Alright! Figured out the guiserver trace problem -- I had "Javaw" associated to %.jar files, not "Java". Javaw is not attached to a console, so it's GUI only. I was able to start my program directly from Java with:
-> mouse-released MAIN:main-canvas MAIN:canvas-clicking true
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.font.FontDesignMetrics$MetricsKey.init(Unknown Source)
at sun.font.FontDesignMetrics.getMetrics(Unknown Source)
at sun.swing.SwingUtilities2.getFontMetrics(Unknown Source)
at javax.swing.JComponent.getFontMetrics(Unknown Source)
at TextShape.hasPoint(TextShape.java:86)
at CanvasWidget$MyCanvas.getTagsFromPoint(CanvasWidget.java:675)
at CanvasWidget$MyCanvas.mouseReleased(CanvasWidget.java:754)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
This appears to be some sort of nasty with Java itself. Any ideas?
Thanks very much!
Testing can show the presence of bugs, but not their absence.
(gs:draw-text 'T "Click to create a node..." 20 30 gs:white)
Commenting that out and tag return works. So, some problem with how I did the text. Have to go finish building a USB typewriter, so I'll investigate that more later, since it's a problem not to be able to do text too...
Testing can show the presence of bugs, but not their absence.
Fixes it. I guess the Java stack trace comes from not having a specified type metric for whatever it is that does the collision detection to determine if you've clicked on a canvas item.
I guess it would be nice if some sensible default was set up so that exception wouldn't get triggered. If I have time for it, I might go digging around in the guiserver and see if I can come up with a patch.
Testing can show the presence of bugs, but not their absence.