Page 1 of 1
Really basic questions about the new form designer
Posted: Sun Dec 30, 2012 11:09 am
by Klonk
Sorry, but I do ot really understand how to use the new form designer.
1. I create a new form within the IDE. Now I want to save it. Which ending to use? .pb or .pbf or something else?
2. I see that some procedures have been created in the newly generated form source? How to use them? Create a project? Include the file somehow?
3. How to use the event procedure?
So basically: How does a normal workflow look like?
Re: Really basic questions about the new form designer
Posted: Sun Dec 30, 2012 11:37 am
by thinkitsimple
same questions here. is there a basic documentation about the new form designer?
Re: Really basic questions about the new form designer
Posted: Sun Dec 30, 2012 12:04 pm
by Polo
Use .pbf - there's no proper help file yet, you can read a very short help draft here:
http://www.purebasic.fr/english/viewtop ... 22&t=52214
Re: Really basic questions about the new form designer
Posted: Fri Mar 22, 2013 4:15 pm
by SniffTheGlove
Could I ask a silly question?
There does not appear to be an Example in the Examples Folder for the Form Designer.
I copied the code out of the only reference I could fine with is just a single page in the help file at
http://www.purebasic.com/documentation/ ... _form.html
... The code from that page is...
Main File "main.pb"
Code: Select all
XIncludeFile "MainWindow.pbf" ; Include the first window definition
XIncludeFile "DateWindow.pbf" ; Include the second window definition
OpenMainWindow() ; Open the first window. This procedure name is always 'Open' followed by the window name
OpenDateWindow() ; Open the second window
; The event procedures, as specified in the 'event procedure' property of each gadget
Procedure OkButtonEvent(EventType)
Debug "OkButton event"
EndProcedure
Procedure CancelButtonEvent(EventType)
Debug "CancelButton event"
EndProcedure
Procedure TrainCalendarEvent(EventType)
Debug "TrainCalendar event"
EndProcedure
; The main event loop as usual, the only change is to call the automatically
; generated event procedure for each window.
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case MainWindow
MainWindow_Events(Event) ; This procedure name is always window name followed by '_Events'
Case DateWindow
DateWindow_Events(Event)
EndSelect
Until Event = #PB_Event_CloseWindow ; Quit on any window close
Now to create the Form files the help file quotes
MainWindow.pbf ; The main window
DateWindow.pbf ; Another window
If we assume MainWindow.pbf has two buttons ('OK' and 'Cancel') and DateWindow.pbf has one calendar gadget, here is how the main file would look like (the main file is not handled by the form designer, it has to be written manually):
I this is where I am getting confused as I created a MainWindow.pbf and a DateWindow.pbf via the Form Designer. I selected the gadgets from the Form Toolbox and placed them on the Forms and saved them. I then ran Main.pb and got Procedure errors as the code in the help file is different to what the Form Designer creates, So I changed the Procuedure names to reflect OpenMainWindow in stead of Open_Window_0 etc and then the gadgets names now appear to be different and I am just going around in circles trying to see where I am going wrong.
Is it possible someone could post the code for MainWindow.pbf and DateWindow.pbf, that way I can understand how it all works. Could it also be possible to maybe add the code to the help file so there is at least a complete working solution and not just half working code. Maybe even create the files and put a copy into the Examples folder of the installation.
Thanks
Re: Really basic questions about the new form designer
Posted: Sat Mar 23, 2013 12:31 pm
by SniffTheGlove
After a few more hours I figured it all out. (At least I think)
I cut out reference to the DateWindow and just tried to get an OK button to work in Debug Window.
OK,
Keep the Main.pb code the same as the help file but delete the following...
XIncludeFile "DateWindow.pbf" call
OpenDateWindow Call
TrainCalendarEvent(EventType) Procedure
Case DateWindow Select
That removes the Datewindow stuff
Now create a new Form and give it a Variable name of MainWindow
Now add a Button to the form, then in the Button's properties select the DropDown box for the Event Procedure and you should see 2 Procedures listed...
OkButtonEvent
CancelButtonEvent
Select the OkButtonEvent and then save the form as MainWindow.pbf
Now goto Main.pb and press F5 to run and clicking the button shows a response in the Debug window.
Simple now once I understand the methodoly
So the finished code looks like
Main.pb
Code: Select all
XIncludeFile "MainWindow.pbf" ; Include the first window definition
OpenMainWindow() ; Open the first window. This procedure name is always 'Open' followed by the window name
; The event procedures, as specified in the 'event procedure' property of each gadget
Procedure OkButtonEvent(EventType)
Debug "OkButton event"
EndProcedure
Procedure CancelButtonEvent(EventType)
Debug "CancelButton event"
EndProcedure
; The main event loop as usual, the only change is to call the automatically
; generated event procedure for each window.
Repeat
Event = WaitWindowEvent()
Select EventWindow()
Case MainWindow
MainWindow_Events(Event) ; This procedure name is always window name followed by '_Events'
EndSelect
Until Event = #PB_Event_CloseWindow ; Quit on any window close
MainWindow.pbf
Code: Select all
Global MainWindow
Global Button_0
Declare OkButtonEvent(EventType)
Procedure OpenMainWindow()
MainWindow = OpenWindow(#PB_Any, 0, 0, 220, 110, "", #PB_Window_SystemMenu)
Button_0 = ButtonGadget(#PB_Any, 70, 30, 80, 30, "OOK")
EndProcedure
Procedure MainWindow_Events(event)
Select event
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case Button_0
OkButtonEvent(EventType())
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
Re: Really basic questions about the new form designer
Posted: Tue Apr 23, 2013 10:17 am
by Skitted
I just put my basic question here too...
What should happen once I click the Tools->Form Designer Menue Item ? Should it open the Designer ? It doesn't...
What is the Toolbox Tap in the Purebasic GUI good for ? I see all the Forms but I can not for example drag one into my code...(which would be cool) Currently it seems I can just scroll through the list, but nothing more, if I want to do anything I need to open the FormDesigner.exe...
I also found an error : Once I create a Button and set the Caption Text to "Click this !" it generates the following code, which does not run, because of the "" missing...
Code: Select all
Button_0 = ButtonGadget(#PB_Any, 120, 140, 360, 90, Click this !)
Kind regards,
Newbie Skitted
P.s. I use PB 5.11
Re: Really basic questions about the new form designer
Posted: Tue Apr 23, 2013 11:34 am
by Lothar Schirm
@Skitted
If you click the Tools -> Form Designer Menue Item, you will only add the Form Designer Toolbox and Object List to your opened tools (e.g. Procedures, Project, File Explorer), if it is not yet. In order to open the Form Designer, you will have to click "Form -> New Form".
You cannot drag and drop controls from the toolbox into your code. You can only click on a control in the Toolbox (e.g. Button) so that you can draw it on your form. You can also drag and drop the button from the Toolbox on the form.
I cannot reproduce your error, using your example, I get a correct code.
Re: Really basic questions about the new form designer
Posted: Tue Apr 23, 2013 8:38 pm
by Polo
If the "" are missing it means you clicked on "use caption as a variable".
Re: Really basic questions about the new form designer
Posted: Fri Apr 26, 2013 6:00 pm
by menschmarkus
If the "" are missing it means you clicked on "use caption as a variable".
yep,
thats the reason why I made my proposal (
http://www.purebasic.fr/english/viewtop ... 22&t=54067)
and the relating tiny tool (
http://www.purebasic.fr/english/viewtop ... 12&t=54371)