
-----------------------------------
GrandAvalon
Sat Jan 10, 2004 8:52 pm

Error with GUI.GetEventWidgetID when dealing with Canvas
-----------------------------------
I am trying to create a card game where you can click and drag a card (multiple full canvases) and move it around the screen.  However, GUI.GetEventWidgetID doesn't seem to get along with the full canvas (Error: "Reference through nil pointer")....  :( 

The following code was used to test GUI.GetEventWidgetID.


import GUI in "%oot/lib/gui"
var canvas : int

procedure nothing (x, y : int)

end nothing

procedure test (x, y : int)
    var a : int
    a := GUI.GetEventWidgetID
end test

canvas := GUI.CreateCanvasFull (10, 10, 30, 40, 1, test, nothing, nothing)

loop
    exit when GUI.ProcessEvent
end loop


-----------------------------------
Dan
Sat Jan 10, 2004 9:14 pm


-----------------------------------
needs to be:

import GUI in "%oot/lib/GUI"

need cpas in the GUI, well at least it is that way on my comp

-----------------------------------
GrandAvalon
Sat Jan 10, 2004 9:23 pm


-----------------------------------
That is not the problem.

-----------------------------------
Andy
Sat Jan 10, 2004 9:26 pm


-----------------------------------
GUI can be very messy, i suggest making ur own... i remember last  yr when i had a problem with the gui textbox, i was making a chatprogram, but whenever someone pressed a key with the gui textbox on the screen the program would crash... i emailed tom west and he told me to declare the textfield before the textbox... y dont u email him and ask about it?

-----------------------------------
GrandAvalon
Sat Jan 10, 2004 9:31 pm


-----------------------------------
How long did it took him to reply?
Becuase I got only around a week to finish this program (its part of my school project).

So this can be classified as urgent

-----------------------------------
Dan
Sat Jan 10, 2004 9:48 pm


-----------------------------------
pfff, tom? he may never reply.

sory, i did not read your question right, why do you need to use the get id thing?

just have a diffrent procedure for every canves and do somting like this:


import GUI in "%oot/lib/GUI"
var canvas : int
var a : int := 0
procedure nothing (x, y : int)

end nothing

procedure test (x, y : int)
    var y1 : int := 0;
    var x1 : int := 0;
    var button : int := 0

    loop
        Mouse.Where (x1, y1, button)
        if button = 1 then
            GUI.SetPositionAndSize (canvas, 10 + (x1-30), 10 + (y1-40), 30, 40)
        end if
    end loop
end test

canvas := GUI.CreateCanvasFull (10, 10, 30, 40, 1, test, nothing, nothing)

loop
    exit when GUI.ProcessEvent
end loop


also this could be done esaser with out the GUI by making your cards in to jpg files loading them and then using the pic comands to move them.

-----------------------------------
GrandAvalon
Sat Jan 10, 2004 10:30 pm


-----------------------------------
Each deck has 52 cards.  I will be doomed if I create a different procedure for each card, not to mention I have though about allowing the user to choose number of decks they want to use... (in casinos they usually have more than 1 deck so people cannot keep track of cards)

-----------------------------------
Tony
Sat Jan 10, 2004 10:36 pm


-----------------------------------
gotta use arrays :roll: you can use arrays to dynamically create card buttons and such. And you can link it all back to a single procedure as long as the card number is passed to it as an argument.

-----------------------------------
Dan
Sat Jan 10, 2004 10:39 pm


-----------------------------------
also you could make the drawing in turing, use pic comans to truing it in to a pichutre then move it that way

-----------------------------------
GrandAvalon
Sun Jan 11, 2004 3:31 pm


-----------------------------------
gotta use arrays :roll: you can use arrays to dynamically create card buttons and such. And you can link it all back to a single procedure as long as the card number is passed to it as an argument.

but when you CLICK on the card, that single procedure woouldn't know who called it unless I have the GUI.GetEventWidgetID crashed-proof.

Of cause I can go through all the IDs on the array and check the X,Y coordinates and the bounds, but that will be both slow, ugly, and annoying

-----------------------------------
Dan
Sun Jan 11, 2004 11:39 pm


-----------------------------------
i still dont get why you HAVE to uses GUI.GetEventWidgetID? in the code i posted you just need a difrent procedure for each canvas...
