I find myself having to deal with some delightful legacy software written in Gambas3. I have to extend the functionality of a small GUI application with a new control page.
Naturally, as for similar GUI libraries I've worked with (web, Android development, flutter, ...) I came looking for a way to navigate between different pages. It is almost implied as possible by the organization in .form files.
Unfortunately, I couldn't find a way to achieve this. Given multiple different Form objects, how can I swap the currently viewed window between them?
How to navigate to a new Form
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: How to navigate to a new Form
Welcome to the forum
I am not sure I fully understand the question but here is a small program switching between 5 TextAreas. If it's not what you want then let me know.Given multiple different Form objects, how can I swap the currently viewed window between them?
Re: How to navigate to a new Form
Thank you!Welcome to the forum
It's a start. I want to have separate "Views" of my application with different purposes (say, a normal usage view + a settings/options view).I am not sure I fully understand the question but here is a small program switching between 5 TextAreas. If it's not what you want then let me know.
In your example you keep all objects into the same Form, hiding all but one of them at any given time. This would achieve my objective, but I was wondering if there was a better way to do it.
In the project I have attached I have two separate forms; I would like to "navigate" (if it makes sense in a Gambas3 context) from the first to the second and return by clicking the buttons.
If this is not possible then my next question would be what is the point of having multiple separate class source files in the same project.
- Attachments
-
- MultiForm.tar.gz
- (12.22 KiB) Downloaded 402 times
Re: How to navigate to a new Form
Hi maldus,
I guess this is what you want to do:
Code for FMain:
If the idea here is to make some sort of wizard have a look at http://gambaswiki.org/wiki/comp/gb.form/wizard
Enjoy..
I guess this is what you want to do:
Code for FMain:
Public Sub Button1_Click()
FSecond.Show
Me.Hide
End
Code for FSecond:
Public Sub Button1_Click()
FMain.Show
Me.Hide
End
You can also use Me.Close on the forms if you like. In code above they stay opened but hidden.If the idea here is to make some sort of wizard have a look at http://gambaswiki.org/wiki/comp/gb.form/wizard
Enjoy..
gbWilly
- Dutch translation for Gambas3
- Gambas wiki content contributer
... there is always a Catch if things go wrong!
- Dutch translation for Gambas3
- Gambas wiki content contributer
... there is always a Catch if things go wrong!
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: How to navigate to a new Form
OK, I think I get it now. Have a look at the attached.
EDIT. It seems gbWilly had the same idea and beat me to it!
EDIT. It seems gbWilly had the same idea and beat me to it!
Re: How to navigate to a new Form
Yes, this was exactly what I was looking for! Thank you for the assistance.
Just one last question. In the example provided by @cogier the window changes position when switching from the first to the second Form. I couldn't find the reason behind this behavior in the code, can someone clarify it for me?
Just one last question. In the example provided by @cogier the window changes position when switching from the first to the second Form. I couldn't find the reason behind this behavior in the code, can someone clarify it for me?
- cogier
- Site Admin
- Posts: 1129
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: How to navigate to a new Form
'Me' refers to the Form so to position the Form you use 'Me. X' for the horizontal position and 'Me. Y' for the vertical position. As the Form is automatically centered all I had to do was change the 'X' position which is in the code I posted.Just one last question. In the example provided by @cogier the window changes position when switching from the first to the second Form. I couldn't find the reason behind this behavior in the code, can someone clarify it for me?