No Generate event loop in Windows version 5.6.

You need some new stunning features ? Tell us here.
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 794
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: No Generate event loop in Windows version 5.6.

Post by Zebuddi123 »

Hi Franb take a look at one of our new members Visual designer implementation, still work in progress it will provide you with full working code and event procedure. As your using a demo you will be limited to compiling 800 lines of code at most. The Zip Download for SweetyVD come with the visual designer pre compiled as 64bit exe if you need an 32bit exe just request one myself or someone here will compile you the code should you want it.

Zebuddi. :)

https://github.com/ChrisRfr/SweetyVD
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: No Generate event loop in Windows version 5.6.

Post by TI-994A »

franb wrote:I am trying the demo version 5.6 in Windows. In my Form preferences there is no option to automatically generate an event loop in the Form Designer.
The newer versions of the form designer have removed the option for generating the event loop, freeing the programmer to process events at their discretion. This is a very minor change that only requires the main event loop to be included in an external file.

Following this small tutorial, Events Handling with the Form Designer, under the section of Using PureBasic Forms, the events file is created in step 10:

Code: Select all

XIncludeFile "MyForm.pbf"

Procedure buttonEvent(eventType.i)
  ;get the text from the text box (identifier = String_0)
  text$ = GetGadgetText(String_0)
  
  ;and place it in the label (identifier = Text_0)
  SetGadgetText(Text_0, text$)  
EndProcedure
Now, simply add the call to the main window procedure and include the main event loop here, like so:

Code: Select all

XIncludeFile "MyForm.pbf"

Procedure buttonEvent(eventType.i)
  ;get the text from the text box (identifier = String_0)
  text$ = GetGadgetText(String_0)
  
  ;and place it in the label (identifier = Text_0)
  SetGadgetText(Text_0, text$)  
EndProcedure


;ADDITION #1: call to the main window procedure
OpenWindow_0()

;ADDITION #2: the main event loop
Repeat
  event = WaitWindowEvent()
Until Window_0_Events(event) = #False
That's all! :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
mestnyi
Addict
Addict
Posts: 995
Joined: Mon Nov 25, 2013 6:41 am

Re: No Generate event loop in Windows version 5.6.

Post by mestnyi »

User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: No Generate event loop in Windows version 5.6.

Post by ChrisR »

TI-994A wrote:
franb wrote: Now, simply add the call to the main window procedure and include the main event loop
It's one of the negative points of PB Form, It would be really nice to have a revision on these 2 points.
It is tiring to have to copy the code into a new tab to be able to add those changes.
In the same way, it would be good to be able to add codes without being destroyed during the Code/Form flip-flop.

@mestnyi It is good to have some challenger, in the good way, not a competition but a good stimulation.
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: No Generate event loop in Windows version 5.6.

Post by TI-994A »

Firstly, they're both great works in progress. Some way to go, so, good luck to both of you.
ChrisR wrote:It is tiring to have to copy the code into a new tab to be able to add those changes.
That is not necessary, as any changes could be saved as regular source files before switching back to design view. But that's not the intended implementation of these form files. They are meant to be used as standalone user interface files that are included and called by the main program. All event processing should be performed within the main program and not in these reusable form files.
ChrisR wrote:...it would be good to be able to add codes without being destroyed during the Code/Form flip-flop.
Not impossible, but the parser would have to work overtime.

BTW, how are the SweetyVD form files saved for future editing? :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: No Generate event loop in Windows version 5.6.

Post by mk-soft »

Caution Advertising.

The event creation I found from Visual designer never as I would have liked.
Therefore I use my tool EventDesigner.
This creates not only the event loop, but also all necessary event-procedures. Subsequent changes are also no problem.

I like to use the visual designer.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: No Generate event loop in Windows version 5.6.

Post by ChrisR »

Yes TI-994A, I use PB Form like that, now.
But at the very beginning, it was a concern for me, as probably for others
For a beginner it would be good to have OpenWindows writen in source and the event loop reviewed
To be able to run Out Of the Box, after copying the source in a new Tab.
And I beleive that the Code generation is not the most complicated part in PB Form.

About editing, it is indeed more complicated.
It should probably be done by reading the source and with perhaps some tags (eg: ;//Begin_PB_Form => //End_PB_Form)
But well, it's not really essential.
And as you suppose, for my "little" tool, I have no plan yet and it is far for now, for such feature :wink:
It is already hard to find time for more complicated things as Container or multiple selection.
It is open source for that, for the pleasure of sharing and for possible contribution but without success for now :cry:

Thanks mk-soft for your eventdesigner :)
I do not know it and I just tested, that's a great addition, especially for large Apps.
It could be an usefull option in a VD.
I would be happy to add it in future, if I go further and if you allow.

Another Idea i have, is to choose a template (skeleton) file for the code generation.
With a preference file and Section to be copied at generation time, like:

Code: Select all

[IncludeFile]

[enumeration]
Line01=#MyFont

[Declare]

[Procedure]
Line01=LoadFont(#MyFont, "Verdana", 8)

[Initialisation]

[EventLoop]

[Exit]
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: No Generate event loop in Windows version 5.6.

Post by TI-994A »

ChrisR wrote:...it would be good to have OpenWindows writen in source and the event loop reviewed To be able to run Out Of the Box, after copying the source in a new Tab.
Technically, form files are purely intended for the design and layout of user interfaces. It is the same with Visual Studio's form designer, Android Studio's layout editor, and even XCode's interface builder; all the forms comprise of static code purely for the creation of the UI and nothing more. They have to be linked to external code modules for event processing.

It's true that the PureBasic form designer initially allowed the inclusion of the event loop within its form files; but in line with current best practices of visual interface builders, the option was removed for better conformity. It is important for beginners to embrace this modular approach, as it would be helpful when crossing between development platforms. :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
ChrisR
Addict
Addict
Posts: 1127
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: No Generate event loop in Windows version 5.6.

Post by ChrisR »

Thanks for your explanation and the history.
I understand for advanced users and for learning the modular approach.

But for me, I have trouble understanding this choice for newbie.
with the option generate event procedure enabled by default during PB install.
A functional code, Out Of The Box should be a priority for me with this option. Regular and advanced users know what to do.
Well, it's probably only my point of view :wink:
Post Reply