Making use of popfont.font

Discuss GUI programming with the RapaGUI plugin here
Post Reply
LarsB
Posts: 72
Joined: Sat May 06, 2017 4:37 pm

Making use of popfont.font

Post by LarsB »

Hi there,

not sure if i should post this on RappaGUI or here..anyway.

Toaday I went through the popfont method. I have extracted the code from the Demo in the RappaGUI examples.
When it comes to Popfont.Font it only shows the name of the selected font in the log beneath the selection fields.
No wonder it only gets the triggervalue and put it into a listview.

Now when I try to set the font via moai.set("example","font",t$) I got now yield.

I tried to boil it down and asking myself how to make use of this method.

here is the .hwp

Code: Select all

@REQUIRE "RapaGUI"
@DISPLAY 1,{X = 50, Y = 200, Width = 420, Height = 340, Color = #WHITE}

@FONT 1,"Arial",48

Function p_Log(t$)

	moai.DoMethod("log", "insert", "bottom",t$)
	
	/*here it comes*/
	moai.Set("example", "font",t$)
	
	moai.DoMethod("log", "jump", "bottom")
	
EndFunction

Function EventFunktion(msg)

	Switch msg.action
	Case "RapaGUI"
		Switch msg.attribute
		Case "Pressed":
			Switch msg.id
										
			Case "hwclear":
				Cls	
												
			Default:
				p_Log("Button click: " .. msg.id)
			EndSwitch
			
		Case "Selected":
			Switch msg.id
			
			Case "mn_quit":
				End
			Case "mn_about":
				moai.Request("", "Widgets demo\n(C) 2015-2016 by Andreas Falkenhahn\n\nVisit the official Hollywood portal at:\nhttp://www.hollywood-mal.com", "OK")				
			Case "mn_aboutrapagui":
				moai.DoMethod("app", "aboutrapagui")																
			EndSwitch		

		Case "Font":
			p_Log(msg.triggervalue)
		
		Case "RGB":
			p_Log("Popcolor: " .. HexStr(msg.triggervalue))	
				
EndSwitch	
EndSwitch
EndFunction

InstallEventHandler({RapaGUI = EventFunktion})
moai.CreateApp(FileToString("PopGUI3.xml"))

Repeat
CheckEvent()	
Forever

and here is the xml which should be PopGUI3.xml

Code: Select all


<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
	
	<menubar id="menu">

		<menu title="_File">
			<item id="mn_about">_About...</item>
			<item id="mn_aboutrapagui">About Rapa_GUI...</item>
			<item/>
			<item id="mn_quit">_Quit</item>
		</menu>
	</menubar>
		
	<window title="Widgets demo" id="window" menubar="menu">
		<vgroup>
		
										
				<vgroup title="Poppers" icon="15">

					<colgroup columns="2">
						

						<label>Font</label>
						<popfont id ="example" title="Please select a font..." notify="font"/>

						<label>Color</label>
						<popcolor title="Please select a color..." notify="rgb"/>											
					</colgroup>			
				</vgroup>							
						
																									
		

			<vgroup frame="true" frametitle="Event logger">
				<listview id="log">
					<column/>
				</listview>	
			</vgroup>							
		
		<text id="text1">hello</text> 
		</vgroup>
	</window>

</application>
Any comments are highly welcome ;)
Lars
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Making use of popfont.font

Post by airsoftsoftwair »

I don't understand. What is the actual problem here?

Btw, don't use CheckEvent() in your main loop but WaitEvent().
LarsB
Posts: 72
Joined: Sat May 06, 2017 4:37 pm

Re: Making use of popfont.font

Post by LarsB »

At the moment I going through the Demo in RappaGUI and tryout the widgets. Sure its pretty clear that you gettin a font requester if you call the widget. But how can I apply the the selected Font? (sorry for the beginner question)

SetFont and moia.set("text1","font","t$) Do not change anything. Maybe I concept the idea behind it. A small snipplet with a practical application of that would be great.
Last edited by LarsB on Sat Sep 21, 2019 3:05 pm, edited 1 time in total.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Making use of popfont.font

Post by airsoftsoftwair »

RapaGUI currently doesn't allow you to apply a font to a widget. This is because MUI doesn't it allow it either. Choosing fonts should be left to the user's prefs.
LarsB
Posts: 72
Joined: Sat May 06, 2017 4:37 pm

Re: Making use of popfont.font

Post by LarsB »

Ok thank you very much for the clearification. So when I want to set the font in a text on a display for exmaple, I got to trick around a little bit. (By doing String Operations to extract the font name and the size to apply it? ) Excuse me.. then the feature is not one of the more specetcular/useful ones? ;) ;)
Post Reply