How to navigate to a new Form

Post

Posted
Rating:
#1 (In Topic #328)
Trainee
 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?
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
Welcome to the forum :D

Given multiple different Form objects, how can I swap the currently viewed window between them?

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.

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
Welcome to the forum
Thank you!

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.
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).
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.

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
Hi maldus,

I guess this is what you want to do:

Code for FMain:

Code (gambas)

  1. Public Sub Button1_Click()
  2.  
  3.   FSecond.Show
  4.   Me.Hide
  5.  
  6.  

Code for FSecond:

Code (gambas)

  1. Public Sub Button1_Click()
  2.  
  3.   FMain.Show
  4.   Me.Hide
  5.  
  6.  

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
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Guru
cogier is in the usergroup ‘Guru’
OK, I think I get it now. Have a look at the attached.

Attachment

EDIT. It seems gbWilly had the same idea and beat me to it! :D
Online now: No Back to the top

Post

Posted
Rating:
#6
Trainee
 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?
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Guru
cogier is in the usergroup ‘Guru’
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?

'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.
Online now: No Back to the top
1 guest and 0 members have just viewed this.