Page 1 of 1

how do I Dynamicaly adding textboxes

Posted: Tue Mar 14, 2023 8:18 am
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

Re: how do I Dynamicaly adding textboxes

Posted: Wed Mar 15, 2023 9:12 am
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

Re: how do I Dynamicaly adding textboxes

Posted: Wed Mar 15, 2023 10:26 am
by Flinx
To make the script functional insert a < character in line 39 between "xx" and "/text>".

Re: how do I Dynamicaly adding textboxes

Posted: Wed Mar 15, 2023 3:27 pm
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

Re: how do I Dynamicaly adding textboxes

Posted: Wed Mar 15, 2023 9:36 pm
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

Re: how do I Dynamicaly adding textboxes

Posted: Thu Mar 16, 2023 2:01 am
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

Re: how do I Dynamicaly adding textboxes

Posted: Sat Mar 18, 2023 10:45 pm
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.

Re: how do I Dynamicaly adding textboxes

Posted: Mon Mar 20, 2023 12:44 am
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

Re: how do I Dynamicaly adding textboxes

Posted: Tue Aug 13, 2024 9:52 pm
by airsoftsoftwair

Code: Select all

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