
-----------------------------------
Wing_Wing
Sat Nov 25, 2006 11:35 pm

how to UNDO?
-----------------------------------
I have this code thing here...

View.Set ("offscreenonly")
var mx, my, mx2, my2, mb, pic : int
loop
    mousewhere (mx, my, mb)
    if mb = 1 then
        pic := Pic.New (0, 0, maxx, maxy)
        loop
            mousewhere (mx2, my2, mb)
            Pic.Draw (pic, 0, 0, picCopy)
            drawbox (mx, my, mx2, my2, black)
            exit when mb not= 1
            View.Update
        end loop
    end if
end loop

and it can draw boxes, but how do i make it so that i can also undo? anyone help me out?

-----------------------------------
CodeMonkey2000
Sun Nov 26, 2006 12:15 am


-----------------------------------
not sure wat u mean by "undo" but if u want 2 get rid of the boxes cls it
and u need to free the pic
View.Set ("offscreenonly")
var mx, my, mx2, my2, mb, pic : int
loop
    mousewhere (mx, my, mb)
    if mb = 1 then
        pic := Pic.New (0, 0, maxx, maxy)
        loop
            mousewhere (mx2, my2, mb)
            Pic.Draw (pic, 0, 0, picCopy)
            drawbox (mx, my, mx2, my2, black)
            exit when mb not= 1
            View.Update
        end loop
        Pic.Free (pic)
    end if
    cls
    View.Update
end loop


-----------------------------------
Wing_Wing
Sun Nov 26, 2006 7:56 pm


-----------------------------------
i mean by pressing keys such as CTRL+Z to undo

-----------------------------------
Tony
Mon Nov 27, 2006 10:47 am


-----------------------------------
you would have to take a screenshot and save it, before drawing a new box. Input.KeyDown to read input, and if it's Ctrl+Z, draw saved image to screen to 'step back'.

Though I think that Ctrl+Z might have a special meaning in Turing.. :think:

-----------------------------------
Prince Pwn
Mon Nov 27, 2006 2:12 pm


-----------------------------------
Yeah for some reason none of the CTRL_ combos work... Probably because Windows uses them.  eg:

var keys : array char of boolean
loop
    Input.KeyDown (keys)
    if keys (KEY_CTRL_Z) then %replace with any key, ctrl doesnt work
        exit
    end if
end loop


-----------------------------------
Prince Pwn
Mon Nov 27, 2006 2:15 pm


-----------------------------------
Wait I just found this in the Turing help menu...

Constants beginning with "KEY_" are char values. These are the values returned by getch and used as an index into the Input.KeyDown array. The constants that the constants KEY_KEYPAD_5, KEY_SHIFT, KEY_CTRL and KEY_ALT can only be used in conjunction with Input.KeyDown. The getch and getchar subprograms do not return these values. All other constants with with SHIFT, CTRL and ALT as part of the name cannot be checked for in the Input.KeyDown array. 

-----------------------------------
Tony
Mon Nov 27, 2006 2:39 pm


-----------------------------------
right, so what you are looking for is

var keys : array char of boolean
loop
    Input.KeyDown (keys)
    if keys (KEY_CTRL) and keys('z') then
        put "Ctrl+z"
    end if
end loop 


-----------------------------------
Prince Pwn
Mon Nov 27, 2006 5:37 pm


-----------------------------------
Cool that way works =D But not in text mode =(

-----------------------------------
Clayton
Mon Nov 27, 2006 5:52 pm


-----------------------------------
won't Ctrl + Z noramally crash Turing during a get though  :think:

-----------------------------------
ericfourfour
Tue Nov 28, 2006 12:45 am


-----------------------------------
won't Ctrl + Z noramally crash Turing during a get though  :think:
Yes it will. I don't remember anyone brining up get though. But I guess that is partly why Tony went over using Input.KeyDown. :D

-----------------------------------
Foundation
Sun Dec 03, 2006 5:40 pm


-----------------------------------
In the help menu there is a portion on what Input KeyDown can take. Look that up, but I'm not sure what you mean when you want it to work in text mode because I'd guess you are doing a paint program for school and work in graphics mode.
