Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Text placed where user clicks
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Neja




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Jan 19, 2004 12:43 am   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Andy




PostPosted: Mon Jan 19, 2004 10:38 am   Post subject: (No subject)

put a delay of 50 milseconds in ur loop
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: