Seite 1 von 1

Eingabe Problem

Verfasst: 15.07.2015 21:56
von bastibasti
Hi,

ich erfasse eine Eingabe in einem Stringgadget, das mit Enter abgeschlossen wird.
die ausgabe wird dann in einen 5 stelliges rotierendes array übergeben und in einem listviewgadget ausgegeben

Manchmal jedoch, wird das erste zeichen nach dem enter gedrückt wurde sofort wieder bestätigt.
jemand ne idee??

(habe den sourcecode mal runtergekürzt)

Code: Alles auswählen


If OpenWindow(#Window, 0, 0, 840, 600, "", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered | #PB_Window_WindowCentered)

     
  TextGadget(2, 440, 0, 75, 25, lang_mainwindow_inputhere)
  StringGadget(3, 380, 25, 200, 25, "")
  AddKeyboardShortcut(#Window, #PB_Shortcut_Return, 100)  ;Eingabefenster soll auf "Enter" eine aktion ausführen
  
    TextGadget(4, 440, 95, 75, 25, lang_mainwindow_lastinput)
  ListViewGadget(5,380,115,200,100)
    
 
  SetActiveGadget(3)

  If CreateMenu(0, WindowID(0))
    MenuTitle( lang_menu_file)
    MenuItem( 7, lang_menu_quit)

    MenuTitle("?")
      MenuItem(11, "About")

  EndIf

  DisableMenuItem(0, 3, 1)
  DisableMenuItem(0, 13, 1)

  Repeat
 ;############## Input enter key in string gadget ###############################################   
   If EventMenu() =  100 And GetActiveGadget() = 3
     input.s=GetGadgetText(3)
     
      If input.s<>""
     SetGadgetText(3, "")
       out.s="OK"
     status.b=1     
     For i=0 To count
        If input.s=suspects(i) 
         out.s="GEFUNDEN: "+input.s
         status.b=2
         found_suspects=found_suspects+1
         loop=0
         EndIf
       Next
     EndIf  
    EndIf
   
   
   ;################ Something in the main window (menu or something) ###############################   
Select WaitWindowEvent(50)
   Case #PB_Event_Menu
        Select EventMenu()  ; To see which menu has been selected
          Case 11 ; About
            MessageRequester("About", "", 0)
          Case 7; quit
            quit=1
        EndSelect
    ;   Case #PB_Event_Gadget
         Case #PB_Event_CloseWindow
        Quit = 1
 EndSelect

; ##### LAST INPUT LIST
; after input, we need to rotate the list ;-) 
If input2.s<>input.s And input<>""
input2=input  
 
list_last_input(5)=list_last_input(4)
list_last_input(4)=list_last_input(3)
list_last_input(3)=list_last_input(2)
list_last_input(2)=list_last_input(1)
list_last_input(1)=input
ClearGadgetItems(5)
For a.b = 0 To 5
  AddGadgetItem(5, a, list_last_input(a))
Next
SetActiveGadget(3)
input=""
EndIf
   
   
Until Quit = 1

EndIf ;open window

End




Re: Eingabe Problem

Verfasst: 15.07.2015 22:09
von man-in-black
Hi,

habs jetzt mal <nicht> getestet, aber mich wundert, dass du:

Code: Alles auswählen

If EventMenu() =  100 And GetActiveGadget() = 3
...
nicht nach Waitwindowevent abhandelst. Also hier:

Code: Alles auswählen

Select WaitWindowEvent(50)
   Case #PB_Event_Menu
        Select EventMenu()
...
Wenn ich mich nicht irre, dann hat sich dein Problem damit in Luft aufgelöst.

MFG
MIB

Re: Eingabe Problem

Verfasst: 15.07.2015 22:16
von bastibasti
Danke!!! :o