Text Input on Mobile

Just starting out? Need help? Post your questions and find answers here.
User avatar
Paul
Posts: 217
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Text Input on Mobile

Post by Paul »

How would I do an equivalent to a EditorGadget using mobile mode since there is no EditorMobile ?

The HtmlMobile command looked promising to do something like

Code: Select all

HtmlMobile("<textarea id='txt1' name='txt1' rows='4' cols='50'></textarea>")
but then how to get the text from it like GetMobileText(#Mobile) command?

The commands available for Mobile seem very limited compared to the commands for Web :(
User avatar
Danilo
Posts: 70
Joined: Wed Feb 26, 2014 7:11 am

Re: Text Input on Mobile

Post by Danilo »

Paul wrote: Tue May 05, 2026 12:53 am

Code: Select all

HtmlMobile("<textarea id='txt1' name='txt1' rows='4' cols='50'></textarea>")
but then how to get the text from it like GetMobileText(#Mobile) command?
You can set and get the text using the .value property:

Code: Select all

Procedure SetTextAreaText(id.s, text.s)
	!var textarea = document.getElementById(v_id);
	!if(textarea) textarea.value = v_text;
EndProcedure

Procedure AppendTextAreaText(id.s, text.s)
	!var textarea = document.getElementById(v_id);
	!if(textarea) textarea.value += v_text;
EndProcedure

Procedure.s GetTextAreaText(id.s)
	!var textarea = document.getElementById(v_id);
	!if(textarea) return textarea.value.toString();
EndProcedure

If ContainerMobile(#PB_Any, #PB_Mobile_Page, "margin:8px")
	HtmlMobile("<textarea id='txt1' name='txt1' rows='4' cols='50'></textarea>")
	HtmlMobile("<br/>")
	HtmlMobile("<textarea id='txt2' name='name' rows='4' cols='50' wrap='off' style='resize:none; color:RGBA(0,200,200,1); background:RGBA(50,50,50,1);'></textarea>")
	
	SetTextAreaText("txt1", "TextArea 1 text.")
	AppendTextAreaText("txt1", ~"\nSome more text.")
	
	SetTextAreaText("txt2", "TextArea 2 text.")
	
	Debug GetTextAreaText("txt1")
	Debug "-----"
	Debug GetTextAreaText("txt2")
	Debug "-----"
	
	CloseMobileContainer()
EndIf
cya,
...Danilo
User avatar
Paul
Posts: 217
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: Text Input on Mobile

Post by Paul »

Thanks Danilo !!!
Exactly what I needed :)
Fred
Site Admin
Posts: 1872
Joined: Mon Feb 24, 2014 10:51 am

Re: Text Input on Mobile

Post by Fred »

Don't hesitate to tell if you miss something in the Mobile UI lib, as I don't personally use it
Post Reply