PureBasic Forum
http://forums.purebasic.com/english/

[Module] StringEx (all OS)
http://forums.purebasic.com/english/viewtopic.php?f=27&t=72534
Page 4 of 4

Author:  Thorsten1867 [ Fri Dec 06, 2019 8:37 am ]
Post subject:  Re: [Module] StringEx (all OS)

Update: Background text added

Code:
StringEx::SetText(#String, "Background Text", StringEx::#Background)

Author:  davido [ Fri Dec 06, 2019 8:16 pm ]
Post subject:  Re: [Module] StringEx (all OS)

@ Thorsten1867,
Excellent. :D
Thank you, very much.

Author:  ozzie [ Sat Dec 07, 2019 12:33 am ]
Post subject:  Re: [Module] StringEx (all OS)

Brilliant! Many thanks.

Author:  Thorsten1867 [ Tue Dec 31, 2019 11:50 am ]
Post subject:  Re: [Module] StringEx (all OS)

Update: Input masks optimized

Code:
; Floats:  "0.00" or "0,000"
; Time:    "00:00"
; Date:    "0000/00/00" or "00.00.0000")
; Cash:    "0,00€" or "$ 0.00"
; License number: "____:____:____:____"

Author:  ozzie [ Sat Jul 25, 2020 9:07 am ]
Post subject:  Re: [Module] StringEx (all OS)

I can't get the tab key to skip to the next field. In the example code I've added calls to ModuleEx::AddWindow and ModuleEx::AddGadget as shown here:
Code:
     If ModuleEx::AddWindow(#Window, ModuleEx::#Tabulator|ModuleEx::#CursorEvent)
       Debug "AddWindow(#Window, ...) OK"
       If ModuleEx::AddGadget(#String, #Window, ModuleEx::#UseTabulator) : Debug "AddGadget(#String, ...) OK" : EndIf
       If ModuleEx::AddGadget(#StringEx, #Window, ModuleEx::#UseTabulator) : Debug "AddGadget(#StringEx, ...) OK" : EndIf
       If ModuleEx::AddGadget(#StringPW, #Window, ModuleEx::#UseTabulator) : Debug "AddGadget(#StringPW, ...) OK" : EndIf
       If ModuleEx::AddGadget(#StringDel, #Window, ModuleEx::#UseTabulator) : Debug "AddGadget(#StringDel, ...) OK" : EndIf
     Else
      Debug "AddWindow(#Window, ...) Failed"
    EndIf
and the function calls are all successful. However, the tab key does not go to the next gadget but focus stays on the current string gadget. (BTW, I changed the #String gadget from a PB gadget to a StringEx gadget.)

Am I missing something? Here's the complete example with the above mods:
Code:
CompilerIf #PB_Compiler_IsMainFile
  XIncludeFile "ModuleEx.pbi"
CompilerEndIf

; (Then the full DeclareModule StringEx code)

;- ========  Module - Example ========

CompilerIf #PB_Compiler_IsMainFile
 
  UsePNGImageDecoder()
 
  #Window  = 0
 
  Enumeration 1
    #String
    #StringEx
    #StringPW
    #StringDel
    #Font
    #Popup
    #Image
    #Menu_Item1
    #Menu_Item2
    #Menu_Item3
    #Menu_Item4
    #Menu_Item5
  EndEnumeration
 
  LoadImage(#Image, "Delete.png")
 
  If OpenWindow(#Window, 0, 0, 460, 60, "Window", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
   
    If CreatePopupMenu(#Popup)
      MenuItem(#Menu_Item1, "Undo")
      MenuBar()
      MenuItem(#Menu_Item2, "Copy")
      MenuItem(#Menu_Item3, "Cut")
      MenuItem(#Menu_Item4, "Paste")
      MenuBar()
      MenuItem(#Menu_Item5, "Delete")
    EndIf
   
    ;StringGadget(#String, 15, 19, 90, 20, "")
    ;SetGadgetAttribute(#String, #PB_String_MaximumLength, 5)
    StringEx::Gadget(#String, 15, 19, 90, 20, "")
   
    StringEx::Gadget(#StringEx, 120, 19, 90, 20, "AutoComplete", StringEx::#AutoComplete, #Window) ; StringEx::#ShowButton / StringEx::#Numeric / StringEx::#LowerCase / StringEx::#UpperCase / StringEx::#NotEditable / StringEx::#BorderLess
    StringEx::AttachPopupMenu(#StringEx, #Popup)
    ;StringEx::SetAttribute(#StringEx, StringEx::#MaximumLength, 5)

    StringEx::AddWords(#StringEx, "Default Define Declare Degree Debug AutoComplete")
   
    StringEx::Gadget(#StringPW, 225, 19, 100, 20, "Password", StringEx::#Password|StringEx::#ShowButton, #Window)
    ;StringEx::SetAttribute(#StringPW, StringEx::#Padding, 6)
    ;StringEx::SetAttribute(#StringPW, StringEx::#MaximumLength, 10)
   
    StringEx::Gadget(#StringDel, 340, 19, 100, 20, "", StringEx::#AutoResize|StringEx::#Right, #Window) ;
    StringEx::AddButton(#StringDel, #Image)
    StringEx::SetAutoResizeFlags(#StringDel, StringEx::#Width)
   
    StringEx::SetText(#StringDel, "Delete Button", StringEx::#Background)
   
    StringEx::SetInputMask(#StringDel, "0.00")
    ;StringEx::SetInputMask(#StringDel, "*.__$")
    ;StringEx::SetInputMask(#StringDel, "*,__ €")
    ;StringEx::SetInputMask(#StringDel, "__.__.____")
   
    CompilerIf Defined(ModuleEx, #PB_Module)
   
       StringEx::SetDynamicFont(#StringDel, "Arial", 8)
       StringEx::FitText(#StringDel, 3, 3)
      
       StringEx::SetAutoResizeFlags(#StringDel, StringEx::#Width|StringEx::#FitText)
      
       ;ModuleEx::SetTheme(ModuleEx::#Theme_Green)
      
     CompilerEndIf
   
    ;DisableGadget(#String, #True)
    ;StringEx::Disable(#StringEx, #True)
   
    ;StringEx::SetAttribute(#StringPW, StringEx::#Corner, 4)
   
     If ModuleEx::AddWindow(#Window, ModuleEx::#Tabulator|ModuleEx::#CursorEvent)
       Debug "AddWindow(#Window, ...) OK"
       If ModuleEx::AddGadget(#String, #Window, ModuleEx::#UseTabulator) : Debug "AddGadget(#String, ...) OK" : EndIf
       If ModuleEx::AddGadget(#StringEx, #Window, ModuleEx::#UseTabulator) : Debug "AddGadget(#StringEx, ...) OK" : EndIf
       If ModuleEx::AddGadget(#StringPW, #Window, ModuleEx::#UseTabulator) : Debug "AddGadget(#StringPW, ...) OK" : EndIf
       If ModuleEx::AddGadget(#StringDel, #Window, ModuleEx::#UseTabulator) : Debug "AddGadget(#StringDel, ...) OK" : EndIf
     Else
      Debug "AddWindow(#Window, ...) Failed"
    EndIf
   
    Repeat
      Event = WaitWindowEvent()
      Select Event
        Case #PB_Event_Gadget
          Select EventGadget()
            Case #StringEx
              Select EventType()
                Case #PB_EventType_Focus
                  Debug ">>> Focus"
                Case #PB_EventType_LostFocus
                  Debug ">>> LostFocus"
                Case StringEx::#EventType_Change
                  Debug ">>> Changed"
              EndSelect   
            Case #StringDel
              If EventType() = StringEx::#EventType_Button
                StringEx::Clear(#StringDel)
              EndIf
          EndSelect
        Case #PB_Event_Menu
          Select EventMenu()
            Case #Menu_Item1
              StringEx::Undo(#StringEx)
            Case #Menu_Item2
              StringEx::Copy(#StringEx)
            Case #Menu_Item3
              StringEx::Cut(#StringEx)
            Case #Menu_Item4
              StringEx::Paste(#StringEx)
            Case #Menu_Item5
              StringEx::Delete(#StringEx)
          EndSelect
      EndSelect       
    Until Event = #PB_Event_CloseWindow
   
    CloseWindow(#Window)
  EndIf
 
CompilerEndIf

Compiling with PB 5.71 under Windows 10, 64-bit.

Page 4 of 4 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/