FlexiGui: How to get text from TextBox gadget?

Started by thaaks, June 30, 2008, 04:24:29 PM

Previous topic - Next topic

thaaks

How do I retrieve the entered text from a textbox gadget?

I tried this:

Select FlexiEvents(EventIndex).EventType

Case FlexEvent_UserHitEnter
; User press enter in a textbox
Select ThisObject
Case DialogInfo.inputFilename
filename$ = Str$(FlexiGetValue(DialogInfo.inputFilename))
#Print filename$
OriginalImage = LoadNewImage(filename$)
EndSelect

where TDialogInfo is a Type and DialogInfo a Dim'ed variable of that type.
filename$ is always "0"...so I guess I'm calling the wrong function.

Must be something simple...

kevin

from memory is it's the FlexiGetCaption function for some reason.


thaaks

Nope.
The text is stored in the GadgetInput field of a TFlexObj. But it seems you cannot retrieve it  ???

The FlexiGetCaption does return the caption for "normal" FlexiObjects and for FlexiGadgets...

I already browsed the FlexiGUI.PBA - without a result...

kevin

This is what i use to get input from a text gadget


Case MapLayersGUI(ThisLayer).NameTextBox
If ThisEvent=FlexEvent_UserKeyStroke Or ThisEvent=FlexEvent_UserHitEnter
s$=FlexiGetCaption(ThisObject)
MapLayers(ThisLayer).name=s$
EndIf
TrappedEvent=True



thaaks

Hmmm, it's too late for me I guess.

Why is this simple example not working?


; PROJECT : PBAnimMapper
; AUTHOR  : Thomas Haaks
; CREATED : 20.06.2008
; EDITED  : 01.07.2008
; ---------------------------------------------------------------------

Explicit False
; include the Flexi GUI library
#Include "FlexiGUI"
Explicit False

SetFPS 60

Type TDialogInfo
labelFilename
inputFilename
buttonLoadFile
EndType

Dim DialogInfo As TDialogInfo

Global DialogWin
Global OriginalImage = 0

DialogWin = FlexiCreate("win", 200, 400)
;FlexiStyle(Dialog,%001)

ypos = 20
yinc = 25
DialogInfo.labelFilename = FlexiCreateLabel("Image file:",10,ypos,DialogWin)
ypos = ypos + yinc
DialogInfo.inputFilename = FlexiCreategadget("textbox",10,ypos,180,20,DialogWin)
ypos = ypos + yinc
DialogInfo.buttonLoadFile = FlexiCreateCmdButton("Load image",10,ypos,100,22,DialogWin)

FlexiOpen(DialogWin)
FlexiPosition(DialogWin,200,0)
FlexiAutoFresh(DialogWin,Timer(),100)


Global Filename$

Do
RenderToScreen
Cls 0
Text 0,0, FPS()

; draw the original image
If OriginalImage <> 0
DrawImage OriginalImage, 0, 0, 0
EndIf



; Call Update Events Function to get new/process existing events
FlexiUpdateEvents()


; ==========================================
; Process the Events
; ==========================================
For EventIndex=0 To flexiState.EventStackSize-1
ThisObject=FlexiEvents(EventIndex).ThisObject


Select FlexiEvents(EventIndex).EventType

Case FlexEvent_UserHitEnter
; User press enter in a textbox
Select ThisObject
Case DialogInfo.inputFilename
Filename$ = FlexiGetCaption(ThisObject)
#Print Filename$
#Break
;OriginalImage = LoadNewImage(Filename$)
EndSelect


Case FlexEvent_UserKeyStroke
sc=FlexiEvents(eventindex).KeyScancode
ik$=FlexiEvents(eventindex).KeyINkey$


Case FlexEvent_UserMouseClick
Select ThisObject
Case DialogInfo.buttonLoadFile
Filename$ = FlexiGetCaption(DialogInfo.inputFilename)
#Print Filename$
#Break
  If (Len(Filename$) > 3 And FileExist(Filename$))
OriginalImage = LoadNewImage(Filename$)
#Break
EndIf
EndSelect


Case FlexEvent_UserWindowFocus
FlexiRenderTo(ThisObject)
bx,by=FlexiGetViewportTop(thisObject)

Case FlexEvent_UserMouseOver
; Catch When the Mouse is over the draw area of a window

Case FlexEvent_UserRedraw

Case FlexEvent_UserOpenWindow
; Catch When a window has been openned

Case FlexEvent_UserCloseWindow
; Catch When the USer CLICKS the close gadget


Case FlexEvent_UserResize
; Catch when a window has been resized

Case FlexEvent_UserMaximized
; Catch  when the user click Maximized button
FlexiRenderTo(ThisObject)
bx,by=FlexiGetViewportTop(thisObject)
Text bx,by,"You maximized me"

Case FlexEvent_UserMinimized
; Catch  when the user click Maximized button
FlexiRenderTo(ThisObject)
bx,by=FlexiGetViewportTop(thisObject)
Text bx,by,"You Minimized me"

Default
FlexiProcessEvent(EventIndex)
EndSelect
Next

RenderToScreen
FlexiRender()
Sync
Loop


The program is not breaking if I hit enter or click the mouse on the button. Why not? The Filename$ is always NULL - how can that be?
Oh, and why are the gadgets not drawn when I start the program but only after I drag the mouse into my dialog window?
FlexiGUI beats me...

I'm off to bed - feedback is welcome  ::)

kevin


  Looked ok to me also, but it seems you're missing flush function after the message pump.   Doesn't seem to work without it..
 

Next
;  Clear the event stack
  FlexiFlushEvents()

RenderToScreen
FlexiRender()
Sync





thaaks

Perfect!
Now it's nearly working as expected. The only thing missing is that the gadgets are only drawn for the first time if the window gets the focus.

Thanks,
Tommy

kevin


Yeah, there's something odd going on with it.  Seems like the gadget isn't being opened during the initial refresh.  It should be drawn when the parent window is Opened.  Without picking through it,  I dunno why it's not