
-----------------------------------
StarGateSG-1
Mon Jul 11, 2005 11:45 pm

TextFields Help
-----------------------------------
Digging my way back into turing isn't easy, so I come to you guys again, with a another problem. I know that it can be fixed I just can't wrap my mind around it. Here it is, the textfiled crashes when you go to enter a letter??

New file, redownload please!

-----------------------------------
Cervantes
Tue Jul 12, 2005 7:01 am


-----------------------------------
I'm not sure if this will fix your problem or not, but you may want to think about keeping everything at the base level.  That is, you declare all your GUI buttons and textfields etc. at the program level, then when you click on something you run a procedure that merely shows some widgets and hides others.
BTW, you misspelled "wrap". :lol:

-----------------------------------
StarGateSG-1
Tue Jul 12, 2005 9:57 am


-----------------------------------
Thank you but I don't think that will work, I will try but I have a feeling that isn't the problem, I will take a closer look though at looking at that, I will fix the spelling mistake tho.

-----------------------------------
Delos
Tue Jul 12, 2005 10:05 am


-----------------------------------
Oh man...
StarGate!  Carrying implicit calls to GUI.ProcessEvent within button action-procedures is not a good idea.  Despite not having the various GUI.ResetQuit()'s you might need to smooth things out...it just complicates matters.
Turing GUI is unstable enough as it is, so you should really only have one main loop that handles it all.  Within this loop, you can have normal, everyday commands going on as well.

One option you might want to look into is instead of opening an entirely new window, you could have all your widgets in one window.  When you click on, say, Load - all widgets that aren't needed are disabled, and those that are  needed are made visible, and enabled.  Once they've done their jobs, reverse.

Or, you could be brave an make your own custom GUI!

-----------------------------------
StarGateSG-1
Tue Jul 12, 2005 10:25 am


-----------------------------------
I can't do that, but yes it would be nicer but if you look at my code, you see that thee is a loading and Saving wondow, so do use your method, I would have to diable all wigets not in use then, change the screen size, I wnat the effect of the other window underneath, I don't think the problem is related to the order they are in.


Here is the problem code form the GUI files.

 % Check widgets
        var widget : ^GenericWidgetBodyClass := WidgetGlobals.firstWidget
        loop
            exit when widget = nil
            if widget -> GetWindow = window and
                    objectclass (widget) >= GenericActiveWidgetClass and
                    GenericActiveWidgetClass (widget).ConsiderKeystroke (ch)
                    then
                % Was a widget shortcut.
                return
            end if
            widget := widget -> GetNext
        end loop

Here is the help file code which runs fine, and is were I got the snytax.


  import GUI
        View.Set ("graphics:200;100") 
        
        var nameTextField, addressTextField : int   % The Text Field IDs.
        
        procedure NameEntered (text : string)
            GUI.SetSelection (addressTextField, 0, 0)
            GUI.SetActive (addressTextField)
        end NameEntered
        
        procedure AddressEntered (text : string)
            GUI.SetSelection (nameTextField, 0, 0)
            GUI.SetActive (nameTextField)
        end AddressEntered
        
        GUI.SetBackgroundColor (gray)
        var quitButton := GUI.CreateButton (52, 5, 100, "Quit", GUI.Quit)
        nameTextField := GUI.CreateTextFieldFull (50, 70, 100, "", 
            NameEntered, GUI.INDENT, 0, 0)
        addressTextField := GUI.CreateTextFieldFull (50, 40, 100, "", 
            AddressEntered, GUI.INDENT, 0, 0)
        var nameLabel := GUI.CreateLabelFull (45, 70, "Name", 0, 0, 
            GUI.RIGHT, 0)
        var addressLabel := GUI.CreateLabelFull (45, 40, "Address", 0, 0, 
            GUI.RIGHT, 0)
        loop
            exit when GUI.ProcessEvent
        end loop
        
        GUI.Dispose (quitButton)
        colorback (gray)
        Text.Locate (maxrow - 1, 1)
        put "Name = ", GUI.GetText (nameTextField)
        put "Address = ", GUI.GetText (addressTextField) ..


Here is my program, as you can see everything is the same.

import GUI
View.Set ("graphics:max;max,nobuttonbar,nocursor,noecho,xor,title:Dark Tides: The Beginnings")
GUI.SetBackgroundColour (gray)

var Map_Canvas, Map_Frame, Message_Frame, Option_Frame, All_Frame, Message_Box : int
var Load_Frame, Load_Box, LoadName, Save_Frame, Save_Box, SaveName, Help_Frame, Help_Box : int
var Load, Save, New, Quit, Help, Ok, Back : int
var Save_Window, Load_Window, Help_Window, NewGame_Window : int
var streamNumber : int
var fileName : string

procedure Active
    View.Set ("invisible")
    Window.SetActive (defWinId)
end Active

procedure FileLoadName (text : string)
    GUI.SetSelection (LoadName, 0, 0)
    GUI.SetActive (LoadName)
end FileLoadName

procedure FileSaveName (text : string)
    GUI.SetSelection (SaveName, 0, 0)
    GUI.SetActive (SaveName)
end FileSaveName

procedure New_Game

end New_Game

procedure Load_Game
    Load_Window := Window.Open ("position:center;center,graphics:600;400")
    GUI.SetBackgroundColour (gray)
    Load_Frame := GUI.CreateFrame (10, 5, maxx - 10, maxy - 3, GUI.EXDENT)
    Load_Box := GUI.CreateTextBox (30, 70, maxx - 60, maxy - 80)
    LoadName := GUI.CreateTextFieldFull (50, 40, 200, "*.sav", FileLoadName, GUI.INDENT, 0, 0)
    Ok := GUI.CreateButton (300, 35, 0, "Open", New_Game)
    Back := GUI.CreateButton (400, 35, 0, "Close", Active)
    streamNumber := Dir.Open (Dir.Current + "/Data/Saved Games")
    assert streamNumber > 0
    loop
        fileName := Dir.Get (streamNumber)
        exit when fileName = ""
        GUI.AddLine (Load_Box, fileName)
    end loop
    Dir.Close (streamNumber)
    loop
        exit when GUI.ProcessEvent
    end loop
end Load_Game

procedure Save_Game
    Save_Window := Window.Open ("position:center;center,graphics:600;400")
    GUI.SetBackgroundColour (gray)
    Save_Frame := GUI.CreateFrame (10, 5, maxx - 10, maxy - 3, GUI.EXDENT)
    Save_Box := GUI.CreateTextBox (30, 70, maxx - 60, maxy - 80)
    SaveName := GUI.CreateTextFieldFull (50, 40, 200, "*.sav", FileSaveName, GUI.INDENT, 0, 0)
    Ok := GUI.CreateButton (300, 35, 0, "Open", New_Game)
    Back := GUI.CreateButton (400, 35, 0, "Close", Active)
    streamNumber := Dir.Open (Dir.Current + "/Data/Saved Games")
    assert streamNumber > 0
    loop
        fileName := Dir.Get (streamNumber)
        exit when fileName = ""
        GUI.AddLine (Save_Box, fileName)
    end loop
    Dir.Close (streamNumber)
    loop
        exit when GUI.ProcessEvent
    end loop
end Save_Game

procedure New_Start

end New_Start

procedure Main
    GUI.Quit
    View.Set ("Invisible")
    %MainScreen
end Main

procedure Help_Game
    Help_Window := Window.Open ("position:center;center,graphics:300;200")
    GUI.SetBackgroundColour (gray)
    Save_Frame := GUI.CreateFrame (3, 3, maxx - 5, maxy - 5, GUI.EXDENT)
    Help_Box := GUI.CreateTextBox (10, 10, maxx - 20, maxy - 20)
end Help_Game

Load := GUI.CreateButton (15, maxy - 25, 0, "New Game", New_Start)
Save := GUI.CreateButton (100, maxy - 25, 0, "Load Game", Load_Game)
New := GUI.CreateButton (185, maxy - 25, 0, "Save Game", Save_Game)
Quit := GUI.CreateButton (270, maxy - 25, 0, "Quit Game", Main)
Help := GUI.CreateButton (355, maxy - 25, 0, "Game Help", Help_Game)

All_Frame := GUI.CreateFrame (0, 0, maxx, maxy, GUI.EXDENT)
Option_Frame := GUI.CreateFrame (maxx - 200, 10, maxx - 10, maxy - 10, GUI.EXDENT)
Map_Frame := GUI.CreateFrame (10, 155, maxx - 220, maxy - 30, GUI.EXDENT)
Map_Canvas := GUI.CreateCanvas (20, 165, maxx - 250, maxy - 200)
Message_Frame := GUI.CreateFrame (10, 5, maxx - 220, 150, GUI.EXDENT)
Message_Box := GUI.CreateTextBox (20, 10, maxx - 250, 135)

loop
    exit when GUI.ProcessEvent
end loop


I tryed moving each piece of code out of a procedure and move them to their own files, but I still got the same error, I want to use this later to Add in Save File, And Open File for the GUI, with modications.

-----------------------------------
jamonathin
Tue Jul 12, 2005 10:30 am


-----------------------------------

Or, you could be brave an make your own custom GUI!
Go with that.  In my opinion, GUI is slow is for lazy people.  You can easily make 90% of the GUI commands without all that much effort, all you have to do is think of what GUI did when it did whatever command, such as a button.

For a button, just:  

var a,b,c,d:int := 100
c:=150
d:=120
var mx,my,mz:int
proc mybutton
drawfilloval(Rand.Int(1,maxx),Rand.Int(1,maxy),20,20,2)
end mybutton
View.Set("offscreenonly")
loop
mousewhere(mx,my,mz)
drawfillbox(a,b,c,d,grey)
if mx > a and my >b and mx 