|
Post by turbov21 on Jan 18, 2008 16:12:11 GMT -5
Here's a prototype of what I think you want: kerovia.net:8008/seaside/go/runbasicpersonal?app=MapTestHere's the code. ' Just need this for this program x$ = "0"
' These hold image map and links data global imagemap$ global linkcount
[start] cls
imagemap$ = "" linkcount = 0
titlebar "Map Test"
' Displays the image html "<div style=""text-align: center; margin: auto;"">" html "<p>Pick a number:</p>" html "<img src=""/1234.gif"" alt=""1234"" usemap=""#numbermap"" border=""0"" />" html "<h1>You chose: " + x$ + "</h1>" html "</div>"
' Builds the map, four links, then displays the map Call StartMap "numbermap" link #link, "", [addone] Call MakeMapLink "0,0,100,100" link #link, "", [addtwo] Call MakeMapLink "100,0,200,100" link #link, "", [addthree] Call MakeMapLink "0,100,100,200" link #link, "", [addfour] Call MakeMapLink "100,100,200,200" Call EndMap
' You have to wait!!! wait
[addone] x$ = "1" goto [start]
[addtwo] x$ = "2" goto [start]
[addthree] x$ = "3" goto [start]
[addfour] x$ = "4" goto [start]
Sub StartMap mapname$ imagemap$ = "<map id=""" + mapname$ + """ name=""" + mapname$ + """>" End Sub
Sub EndMap imagemap$ = imagemap$ + "</map>" html imagemap$ End Sub
Sub MakeMapLink Coordinates$
linkcount = linkcount + 1
js$ = "submitFormTriggeringCallback(document.getElementsByTagName('form')[0].name, '" js$ = js$ + str$(linkcount) + "', 'href' );"
imagemap$ = imagemap$ + "<area shape=""rect"" coords=""" + Coordinates$ + """ onclick=""" + js$ imagemap$ = imagemap$ + """ alt=""" + str$(linkcount) + """ />"
End Sub |
|
|
|
Post by carlgundel on Jan 18, 2008 16:20:58 GMT -5
Well, it's not exactly what I wanted but you know what? It's pretty darn nice! Thanks, -Carl
|
|
|
Post by turbov21 on Jan 18, 2008 16:27:43 GMT -5
Hey Jerry. Thanks, but what I'm looking for is a capture a mouse click on an image, and then to have the coordinates of that click with 0, 0 being the corner or the image. The click should hijack the handler of a link on the page so that the RB app can do something when the user clicks. Think of the cool stuff you could do with this. -Carl Like this? www.emanueleferonato.com/2006/09/02/click-image-and-get-coordinates-with-javascript/
|
|
|
Post by carlgundel on Jan 18, 2008 16:48:12 GMT -5
Hey Jerry. Thanks, but what I'm looking for is a capture a mouse click on an image, and then to have the coordinates of that click with 0, 0 being the corner or the image. The click should hijack the handler of a link on the page so that the RB app can do something when the user clicks. Think of the cool stuff you could do with this. -Carl Like this? www.emanueleferonato.com/2006/09/02/click-image-and-get-coordinates-with-javascript/Right, but of course it needs to invoke a handler and the coordinates need to be available in the RB program. -Carl
|
|
|
Post by turbov21 on Jan 18, 2008 16:55:11 GMT -5
Right, but of course it needs to invoke a handler and the coordinates need to be available in the RB program. -Carl Yup. Let me see what I can do. Two quick questions: can LINK be used in a subroutine, and can you use a string as the third argument (doSomething) for LINK?
|
|
|
Post by carlgundel on Jan 18, 2008 17:08:35 GMT -5
Right, but of course it needs to invoke a handler and the coordinates need to be available in the RB program. -Carl Yup. Let me see what I can do. Two quick questions: can LINK be used in a subroutine, and can you use a string as the third argument (doSomething) for LINK? I'm not sure what you mean. Could you provide some imagined RB code? -Carl
|
|
|
Post by turbov21 on Jan 18, 2008 17:47:02 GMT -5
I'm not sure what you mean. Could you provide some imagined RB code? -Carl Sure! [start] Call MakeLink "[hello]", "Say Hello" wait
[hello] print "Hello" goto [start]
Sub MakeLink TheGoto$, TheText$ link #link, TheText$, TheGoto$ End Sub Obviously the MakeLink subroutine is redundant there, but that shows what I want to do.
|
|
|
Post by carlgundel on Jan 18, 2008 18:15:02 GMT -5
Sure! [start] Call MakeLink "[hello]", "Say Hello" wait
[hello] print "Hello" goto [start]
Sub MakeLink TheGoto$, TheText$ link #link, TheText$, TheGoto$ End Sub Obviously the MakeLink subroutine is redundant there, but that shows what I want to do. No, sorry the handler cannot be a string expression. Guess I'll have to work that into v1.0.1. -Carl
|
|
|
Post by Brent on Jan 18, 2008 23:30:16 GMT -5
Here's something I came up with.
html "<img id=map src=""http://www.debian.org/devel/developers.map.jpeg"" /><br />"
textbox #x, "x" textbox #y, "y"
link #a, "", [get point]
html " <script type=""text/javascript""> <!-- var map = document.getElementById('map'); map.onclick = function(e) { var x, y; if (window.event) { e = window.event; x = e.offsetX; y = e.offsetY; } else { x = e.layerX; y = e.layerY; } var inps = document.getElementsByTagName('INPUT'); for (var i = 0; i < inps.length; i++) { switch (inps[i].value) { case 'x': inps[i].value = x; break; case 'y': inps[i].value = y; break; } } var as = document.getElementsByTagName('A'); for (var i = 0; i < as.length; i++) { if (as[i].onclick && !as[i].firstChild) { as[i].onclick(); break; } } } //--> </script>"
wait
[get point]
x = #x value() y = #y value()
cls print "You clicked the map at (";x;", ";y;")."
end
|
|
|
Post by Brent on Jan 18, 2008 23:41:54 GMT -5
Somewhere else Wow! That's great. But, you posted as a reply to the wrong thread! THANK YOU! -Carl Is this what you're looking for? [get point]
x = #x value() y = #y value()
'cls print "You clicked the map at (";x;", ";y;")." wait I changed the [get point] handler to wait instead of ending the program, and I commented out the CLS. I was hoping that I could click multiple times at different places on the image, but it only ever returns the coordinates from the first click. Is there an easy fix for this? Thanks (so much)! -Carl You're welcome. The form gets submitted by the call to as .onclick(). If you comment out that line, it won't submit. But then the routine relies on the textboxes holding "x" and "y" in order to find them, so if you don't reset them, it won't work.
|
|
|
Post by turbov21 on Jan 19, 2008 0:45:37 GMT -5
Something for v1.02 maybe:
HIDDEN #handle, value$
That way we can have JavaScript stuff coordinate values in a field that won't appear on the screen. (Although, I need to see if I can turn visibility off on the TEXTBOX boxes with CSS.)
|
|
|
Post by mikeukmid on Jan 19, 2008 6:43:51 GMT -5
cssclass "input.text","{ display:none; }"
textbox #tb1,"Hello" wait
Is this what you need?
Mike.
|
|
|
Post by turbov21 on Jan 19, 2008 13:49:06 GMT -5
Is this what you need? Mike. That would be it!
|
|
|
Post by StefanPendl on May 25, 2008 14:07:30 GMT -5
I just found an example, that updates the coordinates by moving the mouse over an image. The only thing missing is mapping the dummy page to the HideMe link. I will work on that one. ' code removed due to the improvements posted below
|
|
|
Post by StefanPendl on May 25, 2008 15:09:04 GMT -5
I have already managed to map the RB link to the Dummy link of the image, but I need to map the onclick action too. ' testing image map print print "Hover over the image to see the coordinates" print
Print "X:"; textbox #X, "" Print Print "Y:"; TextBox #Y, "" Print link #hideMe, "HideMe", [checkCoords] Print
#hideMe SetID("HideMe")
'alt and title must be the same to display tooltip in all browsers 'IE uses alt, all others use title, which is the correct way
html "<p><a id=Dummy href=dummy><img src='../../button.jpg' alt='Area Test' title='Area Test' ismap /></a></p>"
'now do the magic html "<script type='text/javascript'> var MyLink = document.getElementById('HideMe').href document.getElementById('Dummy').href = MyLink </script>" wait
[checkCoords] Coords$ = UrlKeys$
print "Position: "; Coords$
#X Text(Word$(Coords$, 1, ",")) #Y Text(Word$(Coords$, 2, ",")) wait
|
|