Computer Science Canada

Text placed where user clicks

Author:  Neja [ Sun Jan 18, 2004 11:21 pm ]
Post subject:  Text placed where user clicks

I searched for anything similar to this, but I didn't find anything (there were a billion results, I didn't go through them all). I need just a hint, not the code, please, on how to do the text placing like you would find in a simple paint program. But for some reason a) it only lets you do it once and I don't know where to put the loop and b) it doesn't draw the box.

code:
setscreen ("nocursor")

var newx, newy, newb : int := 0
var font, x, y, btnNumber, btnUpDown, a, b : int
var text : string
font := Font.New ("serif:12")

Mouse.Where (newx, newy, newb)

loop
    Mouse.ButtonWait ("down", x, y, btnNumber, btnUpDown)
    newx := x
    newy := y
    loop
        drawbox (113, 66, 640, 400, 7)
        Draw.Box (115, 68, 638, 398, 7)
        drawfill (114, 67, 1, 7)
        Draw.Box (x, y, newx, newy, 0)             
        exit when Mouse.ButtonMoved ("up")
        Mouse.Where (newx, newy, newb)
        Draw.Box (x, y, newx, newy, 7)  % Supposed tod raw a box...
        locatexy (x, y)
        get text % Draw line to position
    end loop
    Font.Draw (text, x, y, font, 7)
    Mouse.ButtonWait ("up", newx, newy, btnNumber, btnUpDown)
    Draw.Box (x, y, newx, newy, 0)             % ...and erase the box.
end loop

Author:  Tony [ Mon Jan 19, 2004 12:43 am ]
Post subject: 

thats because you take your second Mouse.Where too quickly. It is suppost to be ether in the loop of its own...

as for the text, that's another loop where you use getch and Font.Draw to display the text

Author:  Andy [ Mon Jan 19, 2004 10:38 am ]
Post subject: 

put a delay of 50 milseconds in ur loop


: