-
1 Oct 2012 2:38 AM #1
Answered: Ext.img onclick event
Answered: Ext.img onclick event
Hello. Iam using Architect 2 and put on Panel Image like this:
1.how to add from Architect listeners for click method om Image? and it is possible get X and Y coordinates cursor from left,top corner of image?Code:{ xtype: 'panel', title: 'shema', dockedItems: [ { xtype: 'image', dock: 'top', height: 697, id: 'Shema5', itemId: 'Shema5', width: 201, src: 'image/schemaf5.jpg' } ] }
2. it is possible add functional like html tag "map" and "area" to this image.
Thanks. My english bad
-
Best Answer Posted by mice-pace
if all you want to do is do a regular html link on click ScottMartin is right on the money, in the middle of the function (it effectively acts like an onClick) you can just put code to redirect the browser
...If you want Mapping though it gets complicated. Unless there's an easy way (if there is i wouldn't know about it) you can fetch the mouse's position, and use Ext.Img's getPosition function to determine where the image starts... From that you can deduce the offset (how far from the start of the image) the mouse is, and manually code in specific conditionsCode:listeners: { click: { element: 'el', fn: function(){ window.location = "http://www.google.com/"; } } }
(Basically, take the X of the cursor, subtract the X position of the image and the result is how far allong the image's X axis your cursor is... Do the same for the Y and then check if they are inside a specific range to check if they are inside a certain box co-ordinates)
-
2 Oct 2012 7:04 PM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,183
- Vote Rating
- 194
- Answers
- 433
You could try something like:
Scott.Code:listeners: { click: { element: 'el', fn: function(){ } } }
-
2 Oct 2012 7:23 PM #3
if all you want to do is do a regular html link on click ScottMartin is right on the money, in the middle of the function (it effectively acts like an onClick) you can just put code to redirect the browser
...If you want Mapping though it gets complicated. Unless there's an easy way (if there is i wouldn't know about it) you can fetch the mouse's position, and use Ext.Img's getPosition function to determine where the image starts... From that you can deduce the offset (how far from the start of the image) the mouse is, and manually code in specific conditionsCode:listeners: { click: { element: 'el', fn: function(){ window.location = "http://www.google.com/"; } } }
(Basically, take the X of the cursor, subtract the X position of the image and the result is how far allong the image's X axis your cursor is... Do the same for the Y and then check if they are inside a specific range to check if they are inside a certain box co-ordinates)


Reply With Quote