how do I Dynamicaly adding textboxes

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
Redlion
Posts: 111
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

how do I Dynamicaly adding textboxes

Post by Redlion »

HI All,

I am trying to write a program to maintain several SQLite3 databases, I have come across an issue that i can not solve.

Code: Select all

/*** This script requires the RapaGUI plugin*/
@REQUIRE "RapaGUI"
/*** Setup GUI ********************************************************************************************/
moai.CreateApp([[<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
	<window id="dbwin" title=" SQL Database Mender " width="1440" height="1024" notify="closerequest">
		<vgroup>
			<pageview id="tab" fontsize="Big">
				<vgroup title=" Database Data ">
					<listview id="dblist">
						<column title="Row ID" id="rowid">		
						</column>
					</listview>
				</vgroup>
				<vgroup title=" Database Record " id="econtainer">
					<vgroup id="container" frame="true" weight="50">						
						<rectangle/>
					</vgroup>
				</vgroup>
			</pageview>
		</vgroup>
	</window>
</application>]])
/*** RAPAGUI Events ****************************************************************************************/
Function Rapa_Events(msg)
	Switch msg.action
		Case "RapaGUI"
			Switch msg.attribute
				Case "CloseRequest"
					End
			EndSwitch
	EndSwitch		
EndFunction
/*** listen to these events ********************************************************************************/
InstallEventHandler({RapaGUI = Rapa_Events})
; 10 could be from 1 to 60 depending on the Database columns found	
	Xml$ = ""
	For t = 0 To 10
		xml$ = xml$ .. "<hgroup><text id=\"col"..StrStr(t) .. "\"> Col "..StrStr(t) .. "</text> <text id=\"col"..StrStr(t) .. "text\">xx</text></hgroup>"
	Next	
	moai.CreateObject("<vgroup id=\"rlist\">"..xml$.."</vgroup>", "container")
	moai.DoMethod("container", "initchange")
	moai.DoMethod("container", "append", "rlist")
	moai.DoMethod("container", "exitchange", False)	
		
/***  main loop ********************************************************************************************/
Repeat
	WaitEvent
Forever
If I set t in the for next loop to anything under 45 ( I guess the size of the screen ) it only shows the last object added, I have to adjust the size of the screen using the mouse to get it to display all the object that I have added.

Not sure that I am doing something wrong or missed a command to refresh the screen.

Can anyone show me a better way of achieving this.


Edit : it may have something to do with the Pageview object?
Thanks
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
plouf
Posts: 584
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: how do I Dynamicaly adding textboxes

Post by plouf »

Can you post an example that compiles directly and its the minimun size to see what you mean?

Above example do not compile under windows at least
Christos
Flinx
Posts: 261
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: how do I Dynamicaly adding textboxes

Post by Flinx »

To make the script functional insert a < character in line 39 between "xx" and "/text>".
User avatar
Redlion
Posts: 111
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: how do I Dynamicaly adding textboxes

Post by Redlion »

Hi ,

Oops, line 39 was a cut and paste error, trying to get the minimal amount of code that shows the problem.

if you change line 38 to,

Code: Select all

	
	For t = 0 To 45
The text objects are displayed as expected, if i go below 45 it does not display properly only one text object is displayed and I have to adjust the screen height before they will display properly. I have not found a way to automatically refresh the screen so that it will display all the text objects.

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
plouf
Posts: 584
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: how do I Dynamicaly adding textboxes

Post by plouf »

your logic is diffirent and you most probably hit some kind of non-predicted situation in rapagui

by "you logic is diffirent" i mena i see that will be by far more easier and cleaner to use listview like this

Code: Select all

/*** This script requires the RapaGUI plugin*/
@REQUIRE "RapaGUI"
/*** Setup GUI ********************************************************************************************/
moai.CreateApp([[<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
	<window id="dbwin" title=" SQL Database Mender " width="1440" height="1024" notify="closerequest">
		<vgroup>
			<pageview id="tab" fontsize="Big">
				<vgroup title=" Database Data ">
					<listview id="dblist">
						<column title="Row ID" id="rowid">		
						</column>
					</listview>
				</vgroup>
				<vgroup title=" Database Record " id="econtainer">
					<listview id="container">
					  <column title="Column">
					    
					  </column>
					  <column title="Text">
					    
					  </column>
					</listview>
				</vgroup>
			</pageview>
		</vgroup>
	</window>
</application>]])
/*** RAPAGUI Events ****************************************************************************************/
Function Rapa_Events(msg)
	Switch msg.action
		Case "RapaGUI"
			Switch msg.attribute
				Case "CloseRequest"
					End
			EndSwitch
	EndSwitch		
EndFunction
/*** listen to these events ********************************************************************************/
InstallEventHandler({RapaGUI = Rapa_Events})
; 10 could be from 1 to 60 depending on the Database columns found	

	For t = 0 To 10
		pos = moai.DoMethod("container", "Insert", -1, "column "..StrStr(t),"xx")
	Next	
	
		
/***  main loop ********************************************************************************************/
Repeat
	WaitEvent
Forever
Christos
User avatar
Redlion
Posts: 111
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: how do I Dynamicaly adding textboxes

Post by Redlion »

Hi plouf,

I think you have missed the point, I am not wanting to use a Listview on the second page I want to use Text and textentry. I want to be able to display a record on the second page and able to see all the info from all columns at once.

The number of text and textentry objects are determined by the database that I want to edit. ( many different sizes databases ) This database is displayed in the listview on the first page. Editing in the list view is not practical as the amount of info ( sometimes 400 - 600 characters ) stored in each column does not always fit on the screen.

When the database is loaded into page one, the idea was to setup page two with a blank template of a record for that database. when the database is loaded page the text and textentry objects should be created, this is where the problem is. All he objects seem to be created on top of each other and I have to adjust the size of the window to get the objects to display properly. However when there are more than 45 columns in the database page two displays properly.

That is what the program in my initial post is trying to show. I was not sure it was a bug or a programing error. When I tried it on page one is seem to work.

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
User avatar
airsoftsoftwair
Posts: 5626
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: how do I Dynamicaly adding textboxes

Post by airsoftsoftwair »

This looks like a RapaGUI bug to me. It's working correctly with MUI but on Windows I can reproduce the issue. I'll fix that for the next version. Until then, you might be able to work around it by recreating the whole tab, e.g. use Pageview.Remove to remove the old tab, then create a new tab and add it using Pageview.Append.
User avatar
Redlion
Posts: 111
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: how do I Dynamicaly adding textboxes

Post by Redlion »

@ airsoftsoftwair

Thanks for looking into to it for me, I was not sure I was doing something stupid and could not see it.

Thanks
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
User avatar
airsoftsoftwair
Posts: 5626
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: how do I Dynamicaly adding textboxes

Post by airsoftsoftwair »

Code: Select all

- Fix [Windows/macOS/Linux]: Adding objects to a framed group within a pageview caused refresh problems
Post Reply