Guiserver events and others

Started by newdep, January 08, 2008, 02:36:55 PM

Previous topic - Next topic

newdep

Lutz,



1) What GS needs is a generic (gs:clear-events)

(clears any events, flush GS or clear blocking events..as long as

the events are gone when this is called)





2) gs:get-text is very instable on text-fields. (im giving up..)



Using (gs:get-text) in a blocking manner GS is not fast enought to handle

multiple gs:get-text requests from i.e. 1x press button action.

GS crashes during base64 decoding of the multiple get-text fields....

(a MOUSE is used to switch between the test-fields and not <enter> ..

Yes with 1x get-text request no problems at all..)



Having multiple non-blocking gs:get-text events in i.e.

in a 1 button press action, GS is unabel to handle the events Asynchrone.

This results in pressing the button X times the amount of gs:get-text

actions are defined to get the result..the results always come after another..







Norman.
-- (define? (Cornflakes))

Lutz

#1
Quotegs:get-text is very instable on text-fields. (im giving up..)


what are you trying to do? Can you give an example?



Lutz



ps: never give up ;-)

newdep

#2
I have a Panel.

In that panel is ->

1x list-box

1x text-field a

1x text-field b

1x button "add"



pressing button "add" result in an button-action.



*** blocking mode ***



"Add" Button-action includes ->



(define (button-action tag)

...

(gs:get-text 'Text-field_A)

(gs:get-text 'Text-field_B)

..

..

)





* Now when the Panel is open and I move my mouse over text-field A

and type text and then move to Text-field B and type text.. im always getting

 these kind of messages (this is odd behaviour sometimes even with 1 get-text on a text-field it happens too.. depends on how quick you

type and press the "add" button..)->







missing parenthesis : "... [text]Z2hkZmRoZmg=[/text]))n       "

called from user defined function gs:listen

$ server shutdown











*** NON blocking mode ***



"Add" Button-action includes ->



(define (button-action tag)

..

..

(define (get-text_A x y) (set 'txt1 (base64-dec y)))

(define (get-text_B x y) (set 'txt2 (base64-dec y)))



(gs:get-text 'Text-field_A 'get-text_A)

(gs:get-text 'Text-field_B 'get-text_B)

..

..

)



Now when moving the mouse over text-fields a and typing text and

then moving mouse to field b and typing text the "add" button-action

always returns first txt1 with text..but txt2 is nil...pressing again the "add"

button gives me txt1 and txt2... Now I want both txt1 and txt2 at the same time when the "add" button is pressed...seems impossible?





hope the concept is clear?



Norman











PS: just corrected the above examples
-- (define? (Cornflakes))

Lutz

#3
Thanks for the instructions, but just give me a little program I can run.



Lutz

newdep

#4
;;

;; GS: BLOCKING GET_TEXT EXAMPLE!

;; run this exmaple.

;; enter some text,  quickly from field to field and press the button meanwhile.

;; dont press the <enter> by hand

;; switch with your mouse between fields.

;; this will generate an error like ->

;;

;; missing parenthesis : "...))n                                 "

;; called from user defined function gs:listen

;;





(load (append (env "NEWLISPDIR") "/guiserver.lsp"))

(gs:init)



(gs:frame             'F  100 100 300 150 "BLOCKING gs:get-text test")

(gs:set-visible 'F true)



(gs:dialog            'A 'F "get-text" 330 150 nil true)

(gs:set-grid-layout   'A 4 1)

(gs:text-field        'B 'gs:no-action 40)

(gs:text-field        'C 'gs:no-action 40)

(gs:text-field        'D 'gs:no-action 40)

(gs:button            'E 'action_E "get text fields")

(gs:add-to            'A 'B 'C 'D 'E)



(gs:set-visible 'A true)



(define (action_E tag txt )

 (println (gs:get-text 'B))

  (println (gs:get-text 'C))

   (println (gs:get-text 'D)) )





(gs:listen)
-- (define? (Cornflakes))

newdep

#5
;;

;; GS: NONE BLOCKING GET_TEXT EXAMPLE!

;; run this exmaple.

;;

 ;; Target!! -> display ALL fields ONLY when they are all NOT empty/nil !

;;

;; fill the text field with text, dont press <enter>! but use the

;; mouse to switch between fields, then press the button.

;;

;; result -> button action_E cant display all 3 fields in 1 click event!

;;



(load (append (env "NEWLISPDIR") "/guiserver.lsp"))

(gs:init)



(gs:frame             'F  100 100 300 150 "NONE BLOCKING gs:get-text test")

(gs:set-visible 'F true)



(gs:dialog            'A 'F "get-text" 330 150 nil true)

(gs:set-grid-layout   'A 4 1)

(gs:text-field        'B 'gs:no-action 40)

(gs:text-field        'C 'gs:no-action 40)

(gs:text-field        'D 'gs:no-action 40)

(gs:button            'E 'action_E "get text fields")

(gs:add-to            'A 'B 'C 'D 'E)



(gs:set-visible 'A true)





(define (action_E tag txt )



 ;; how to catch multiple , not nil/empty, text-field entry's in a none-blocking way?

 ;; they all return a text or nil (assume having 100+ text-fields?)

 ;; below is NOT the way to do it.



 (define (action_B tag txt) (if (not (nil? txt)) (set 'BT (base64-dec txt))))

 (define (action_C tag txt) (if (not (nil? txt)) (set 'CT (base64-dec txt))))

 (define (action_D tag txt) (if (not (nil? txt)) (set 'DT (base64-dec txt))))



 (gs:get-text 'B 'action_B)

 (gs:get-text 'C 'action_C)

 (gs:get-text 'D 'action_D)





 ;; now assume the users changes the fields meanwhile and the field are now

 ;; all not nil? you have a mixedup result of previous fields entry's instead

 ;; of all the actual data.



 (println "B: " BT)

 (println "C: " CT)

 (println "D: " DT)



)



(gs:listen)
-- (define? (Cornflakes))

newdep

#6
above the two script..blocking and none-blocking

two different issues.



Norman.
-- (define? (Cornflakes))

newdep

#7
reposted the none-blocking example..



Hope you understand the problem of the noen-blocking example.?



The none-blocking exmaple is used because the blocking get-text

does crash.. the none-blocking example is unable to display all

text fields at once when all text fields are all not empty & not nil.



Secondly the none-blocking example returns previsous text-field values.
-- (define? (Cornflakes))

Lutz

#8
You have to move the get-text handler definitions out of the definition of the button handler because they are called asynchronously by gs:listen.



This one works:


;; non-blocking text-field(s)

(load (append (env "NEWLISPDIR") "/guiserver.lsp"))
(gs:init)

(gs:frame 'F 100 100 300 150 "NONE BLOCKING gs:get-text test")
(gs:set-visible 'F true)

(gs:dialog 'A 'F "get-text" 330 150 nil true)
(gs:set-grid-layout 'A 4 1)
(gs:text-field 'B 'gs:no-action 40)
(gs:text-field 'C 'gs:no-action 40)
(gs:text-field 'D 'gs:no-action 40)
(gs:button 'E 'action_E "get text fields")
(gs:add-to 'A 'B 'C 'D 'E)

(gs:set-visible 'A true)

(define (action_B tag txt) (if (not (nil? txt)) (println "B: " (base64-dec txt))))
(define (action_C tag txt) (if (not (nil? txt)) (println "C: " (base64-dec txt))))
(define (action_D tag txt) (if (not (nil? txt)) (println "D: " (base64-dec txt))))

(define (action_E tag txt )
(gs:get-text 'B 'action_B)
(gs:get-text 'C 'action_C)
(gs:get-text 'D 'action_D)
)

(gs:listen)


and here is the blocking version. The button must be disabled during the blocking calls to gs:get-text to make it work reliable:


;; blocking text-field(s)

(load (append (env "NEWLISPDIR") "/guiserver.lsp"))
(gs:init)

(gs:frame 'F 100 100 300 150 "NONE BLOCKING gs:get-text test")
(gs:set-visible 'F true)

(gs:dialog 'A 'F "get-text" 330 150 nil true)
(gs:set-grid-layout 'A 4 1)
(gs:text-field 'B 'gs:no-action 40)
(gs:text-field 'C 'gs:no-action 40)
(gs:text-field 'D 'gs:no-action 40)
(gs:button 'E 'action_E "get text fields")
(gs:add-to 'A 'B 'C 'D 'E)

(gs:set-visible 'A true)

(define (action_E tag txt )
  (gs:disable 'E)
  (println (gs:get-text 'B))
  (println (gs:get-text 'C))
  (println (gs:get-text 'D))
  (gs:enable 'E)
)

(gs:listen)


Lutz

newdep

#9
Thanks for the hint that was some headbreaking to figure that out..(for me :-)

I go for the disable button option, also suits good for the applet.



Thanks..
-- (define? (Cornflakes))

newdep

#10
No the gs:disable does not work here... still the same problem..



Even when I put them around eveny get-text event its happens..



Mmmmmm Im now trying the none-blocking way.. ;-) hold on...
-- (define? (Cornflakes))

newdep

#11
The none-blocking works yes but this is what I had too, the issue is that

you have to press more than onces when you use a 'set inside the function ->



(define (action_B tag txt) (if (not (nil? txt)) (set 'BT (base64-dec txt))))

(define (action_C tag txt) (if (not (nil? txt)) (set 'CT (base64-dec txt))))

(define (action_D tag txt) (if (not (nil? txt)) (set 'DT (base64-dec txt))))



These BT CT DT always run behind the real vaules in the fields..



because the target is -> displaying all fields when they are NOT nil or empty.





clearing them here does not work..



(define (action_E tag txt )



   (set 'BT "" 'CT "" 'DT "")



   (gs:get-text 'B 'action_B)

   (gs:get-text 'C 'action_C)

   (gs:get-text 'D 'action_D)

)





so this result in a big function per get-text action finaly.. its not very practicle

when you have lots of input fields...



If get-text would NOT return a base64 encoded string (its a string anyway)

it would be more simpler too..



any idea?
-- (define? (Cornflakes))

newdep

#12
the only solution I found so far, which is not elegant is putting a (sleep 500)

inbetween the three gs:get-text actions..



This enables them to be all evaluated.. Because these events dont

know from one another that they have data..(async problem)..



This also enables the main 'define to continue..



Its not a save way this (sleep 500) because it does not garanty data..

(which is what i need/check..)





Any other option is very welcome ;-)
-- (define? (Cornflakes))

newdep

#13
Lutz,



If you get nlist v0.36 you can experience the behavior.



gs:get-text is not stable, I also encounter problems

when only having 1 text-field and gs:get-text in blocking mode.

There must be a way to fix this because its a horror using this

on tables having multiple text-field..



Norman.
-- (define? (Cornflakes))

Lutz

#14
gs:get-text in blocking mode is only safe in an situation with no pending events or newly generated events, which could cause gs:get-text or other blockng gs calls to happen. For nlist I would use non-blocking mode.



Blocking mode is done by waiting for the correct response and at the same time evaluating incoming events of different sources. But if those other events in turn trigger blocking gs:get-text, you get into a reentrance situation, which is not handled. The blocking gs:get-text mode has been added for simple situations, where you can guarantee, that reentrance will not occur.



What you could do, is define your own gs:check-event for usage in the blocking mode of gs:get-text. But I would rather go for the asynchronous mode of gs:get-text.



Lutz