Guiserver, GTK-server, OpenGL, PostScript,  
HTML 5, MIDI, IDE
			
		
		
			
				
																			
								hotcore 							 
									
		Posts:  29  		Joined:  Fri Aug 26, 2011 1:03 pm 		
		
						
						
		 
		
						
						
													
							
						
									
						Post 
					 
								by hotcore   »  Fri Aug 10, 2012 12:00 pm 
			
			
			
			
			Hi,
having written my first little newlisp app after lurking now and then on this forum, I have a small problem.
In the code below, when I do NOT enter anything in the input field and push the f->c button, the buttonhandler seems not to work.
The println is not executed! What am I doing wrong?
Thx, Arie
Code: Select all 
(load (append (env "NEWLISPDIR") "/guiserver.lsp"))
(define (f2c x)
	(set 'y (float x nil))
	(println "y=" y ";")
	(cond
		(y (string (div (sub y 32.0) 1.8)))
		(true "enter a number")
	)
)
(define (c2f x)
	(set 'y (float x nil))
	(cond
		(y (string (add (mul y 1.8) 32.0)))
		(true "enter a number")
	)
)
(gs:init)
(gs:frame 'Convert 300 300 270 120 "Convert Fahrenheit & Celsius")
(gs:set-resizable 'Convert nil)
(gs:set-border-layout 'Convert)
(gs:panel 'Input)
(gs:set-flow-layout 'Input "left")
(gs:label 'Inlab "Input value:" "left" 44)
(gs:text-field 'Inval 'text-handler 20)
(gs:add-to 'Input 'Inlab 'Inval) 
(gs:panel 'Output)
(gs:set-flow-layout 'Output "left")
(gs:label 'Outlab "Output value:" "left" 35)
(gs:label 'Outval "")
(gs:add-to 'Output 'Outlab 'Outval)
(gs:panel 'Button)
(gs:set-grid-layout 'Button 1 2)
(gs:button 'f2c 'button-handler "Convert F -> C")
(gs:button 'c2f 'button-handler "Convert C -> F")
(gs:add-to 'Button 'f2c 'c2f)
(gs:add-to 'Convert 'Input "north" 'Output "center" 'Button "south")
(gs:set-visible 'Convert true)
(define (text-handler id value) nil)
(define (button-handler id value)
	(cond
		((= id "MAIN:f2c")
			(gs:set-text 'Outval (f2c (gs:get-text 'Inval))))
		((= id "MAIN:c2f")
			(gs:set-text 'Outval (c2f (gs:get-text 'Inval))))
		(true
			(gs:set-text 'Outval "invalid id detected"))
	)
)
(gs:listen)
 
			
			
									
									
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
																			
								hotcore 							 
									
		Posts:  29  		Joined:  Fri Aug 26, 2011 1:03 pm 		
		
						
						
		 
		
						
						
													
							
						
									
						Post 
					 
								by hotcore   »  Fri Aug 10, 2012 5:10 pm 
			
			
			
			
			It seems that, when you don't do a set-text for a text-field (or fill it in in the form manually) that get-text for that text-field gets stuck somehow. 
 
The same behavior occurs when you empty the text-field at some stage (delete all chars in it). 
 
Any ideas? 
 
Thx, 
 Arie
			
			
									
									
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
																			
								Lutz 							 
									
		Posts:  5289  		Joined:  Thu Sep 26, 2002 4:45 pm 		
		
																Location:  Pasadena, California 
							
							
				Contact: 
				
			 
				
		 
		
						
						
													
							
						
									
						Post 
					 
								by Lutz   »  Fri Aug 10, 2012 7:48 pm 
			
			
			
			
			Initialize the text field to some inital non-empty string, e.g. a space:
Code: Select all 
(gs:text-field 'Inval 'text-handler 20)
(gs:set-text 'Inval  " ")
I also would increase the height of the Convert frame from 270 to 400 when on Mac OSX for the textfield not to be squished.
 
			
			
									
									
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
																			
								hotcore 							 
									
		Posts:  29  		Joined:  Fri Aug 26, 2011 1:03 pm 		
		
						
						
		 
		
						
						
													
							
						
									
						Post 
					 
								by hotcore   »  Sat Aug 11, 2012 9:51 am 
			
			
			
			
			Thanks Lutz! 
 
I already tried that. But when the user empties the field, the same problem will still occur ... 
 
Is there a way (apart from get-text) to see if a field is in such an uninitialized state? 
 
BTW many thanks for this wonderful language!
			
			
									
									
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
																			
								Lutz 							 
									
		Posts:  5289  		Joined:  Thu Sep 26, 2002 4:45 pm 		
		
																Location:  Pasadena, California 
							
							
				Contact: 
				
			 
				
		 
		
						
						
													
							
						
									
						Post 
					 
								by Lutz   »  Sat Aug 11, 2012 4:19 pm 
			
			
			
			
			The relevant function in the text-field widget in guiserver.jar was not handling empty text correctly when text was requested via gs:get-text.
This is now fixed in version 1.47 of Guiserver available here:
http://www.newlisp.org/downloads/develo ... server.jar 
Ps: there will also be a newLISP maintenance release 10.4.4 in September, where the fixed guiserver.jar will be included.
 
			
			
									
									
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
																			
								hotcore 							 
									
		Posts:  29  		Joined:  Fri Aug 26, 2011 1:03 pm 		
		
						
						
		 
		
						
						
													
							
						
									
						Post 
					 
								by hotcore   »  Sat Aug 11, 2012 6:15 pm 
			
			
			
			
			Wow, Lutz you are a genius ;-) 
Thanks a lot for the quick fix! 
 
/Arie
			
			
									
									
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
																			
								Tatiana_Sn 							 
									
		Posts:  3  		Joined:  Mon Aug 19, 2019 9:03 am 		
		
																					Location:  Russian 
							
							
				Contact: 
				
			 
				
		 
		
						
						
													
							
						
									
						Post 
					 
								by Tatiana_Sn   »  Sun Jun 26, 2022 9:04 am 
			
			
			
			
			Is there any word on when an update for desktop is going to be available that allows it to work with WMP 11?   
 
For the time being I have rolled my WMP back to version 10 so I can still use XaMp Desktop.
			
			
									
									Life is Beautiful
						 
		 
				
		
		 
	 
	 
				
		
		
			
				
																			
								Tatiana_Sn 							 
									
		Posts:  3  		Joined:  Mon Aug 19, 2019 9:03 am 		
		
																					Location:  Russian 
							
							
				Contact: 
				
			 
				
		 
		
						
						
													
							
						
									
						Post 
					 
								by Tatiana_Sn   »  Fri Jul 01, 2022 1:28 am 
			
			
			
			
			It seems that, when you don't do a set-text for a text-field (or fill it in in the form manually) that get-text for that text-field gets stuck somehow.  The same behavior occurs when you empty the text-field at some stage (delete all chars in it).  Any ideas?  Thx, Arie
  
Your kind words warmed my heart))
 
			
			
									
									Life is Beautiful