It is currently Thu Dec 12, 2019 4:29 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: [Module] StringEx (all OS)
PostPosted: Wed Mar 27, 2019 4:55 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1031
Location: Germany
StringEx - Module (all OS / 64Bit / DPI)

  • AutoComplete function (Return key)
  • Password input with "Show-Button" (shows password only as long as button is pressed)
  • optional button for triggering an event (e.g. delete text)

Image

Download: StringExModule.pbi

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules

[Windows 10 x64] [PB V5.7x]


Last edited by Thorsten1867 on Sat Nov 23, 2019 2:54 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Wed Mar 27, 2019 6:47 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Jun 23, 2014 1:18 pm
Posts: 165
First try… and workes great :-)


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 3:09 am 
Offline
Enthusiast
Enthusiast

Joined: Sun Apr 06, 2008 12:54 pm
Posts: 379
Location: Brisbane, Qld, Australia
Looks good, but the first click on one of the buttons (show password or delete) is ignored. Need to click a second time for the action to occur.

_________________
Mike
www.showcuesystems.com


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 7:56 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1031
Location: Germany
Bugfixes

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 9:34 am 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 619
Hi!

I got some trouble starting your StringEx-Modul example.

In debug mode there is only an empty window showing up.
Without debug all seems to be allright, all gadgets are there.

I inserted then some debug lines to find out, that the modul
hangs in this line:
Code:
    String::Gadget(#StringPW, 225, 19, 100, 20, "Password", String::#Password|String::#ShowButton)

Here the modul example with debug:
Code:
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)
   Debug "StringGadget"
    String::Gadget(#StringEx, 120, 19, 90, 20, "AutoComplete", String::#AutoComplete) ; String::#ShowButton / String::#Numeric / String::#LowerCase / String::#UpperCase / String::#NotEditable / String::#BorderLess
    Debug "String::Gadget(#StringEx)"
    String::AttachPopupMenu(#StringEx, #Popup)
    Debug "PopUp attached"
    ;String::SetAttribute(#StringEx, String::#MaximumLength, 5)
    String::AddWords(#StringEx, "Default Define Declare Degree Debug AutoComplete")
    Debug "AddWords"
    String::Gadget(#StringPW, 225, 19, 100, 20, "Password", String::#Password|String::#ShowButton)
    Debug "String::Gadget(#StringPW)"
    String::Gadget(#StringDel, 340, 19, 100, 20, "Delete this")
    Debug "String::Gadget(#StringDel)"
    String::AddButton(#StringDel, #Image)
    Debug "AddButton(#StringDel)"
   
    Repeat
      Event = WaitWindowEvent()
      Select Event
        Case #PB_Event_Gadget
          Select EventGadget()
            Case #StringDel
              If EventType() = String::#EventType_Button
                String::Clear(#StringDel)
              EndIf
          EndSelect
        Case #PB_Event_Menu
          Select EventMenu()
            Case #Menu_Item1
              String::Undo(#StringEx)
            Case #Menu_Item2
              String::Copy(#StringEx)
            Case #Menu_Item3
              String::Cut(#StringEx)
            Case #Menu_Item4
              String::Paste(#StringEx)
            Case #Menu_Item5
              String::Delete(#StringEx)
          EndSelect
      EndSelect       
    Until Event = #PB_Event_CloseWindow
   
    String::Free(#StringEx)
   
    CloseWindow(#Window)
  EndIf
 
CompilerEndIf

After adding some debug statements in your modul, the last
successful line was:
Code:
  Procedure Gadget(GNum.i, X.i, Y.i, Width.i, Height.i, Content.s="", Flags.i=#False, WindowNum.i=#PB_Default)
    Define Result.i, txtNum
   
    Result = CanvasGadget(GNum, X, Y, Width, Height, #PB_Canvas_Keyboard)
    If Result:Debug "Result= "+result
     
      If GNum = #PB_Any : GNum = Result : EndIf: Debug "GNum="+gnum; <------------here--------------
     
      If AddMapElement(StrgEx(), Str(GNum)):Debug "AddMapElement"
...
...
      EndIf
      Debug "After AddElement()"
    EndIf
   
  EndProcedure


The debug output shows:
Quote:
StringGadget
Result= 32573484
GNum=2
AddMapElement
ShowPWButton enabled
Windows: GetGadgetFont()
Windows: Color
Before BindGadgetEvent()
finished burron creation
After AddElement()
String::Gadget(#StringEx)
PopUp attached
AddWords
Result= 22744230
GNum=3
Then it hangs. Any ideas?
Tested on Win7x65UltimateSP1, PB5.70LTSx64

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 11:03 am 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1031
Location: Germany
  • Bugfixes
  • Added: Ctrl-Cursor/ Tabulator (AutoComplete)

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 2:00 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 619
Hi!
Thorsten1867 wrote:
  • Bugfixes
  • Added: Ctrl-Cursor/ Tabulator (AutoComplete)
No Change to above.
Still blank window in debug mode.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 2:18 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1031
Location: Germany
Lord wrote:
No Change to above.
Still blank window in debug mode.


I can't understand the mistake because it doesn't occur to me.
Does this happen with my test code or in your own program?

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 4:29 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jul 07, 2013 11:35 am
Posts: 450
Location: Canada
Hello,

When I run the example I get this message : The Debugger executable quit unexpectedly.
Nothing happen without the debugger, I'm under Ubuntu 18.10 x64 and I'm using PureBasic 5.70 LTS

Best regards
StarBootics

_________________
The Stone Age did not end due to a shortage of stones !


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 5:34 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 619
Thorsten1867 wrote:
Lord wrote:
No Change to above.
Still blank window in debug mode.


I can't understand the mistake because it doesn't occur to me.
Does this happen with my test code or in your own program?

See 5 postings above. It's your code included in your module.
It only happens with debugger off, but I didn't try any other code.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 5:40 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1031
Location: Germany
Maybe it's a problem with GetActiveWindow().
I have now added the window number in the example.

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 7:59 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 619
Hi!

Thorsten1867 wrote:
Maybe it's a problem with GetActiveWindow().
I have now added the window number in the example.
No change. Tested the latest version.
See for yourself what it looks like.:
https://bayfiles.com/Y1i9Y9U2m4/2019-03-28-19-51-46_mp4

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Thu Mar 28, 2019 8:19 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 619
I did some testing.

I found out, that
1. GetActiveWindow is here never executed, IsWindow(WindowNum) is always #True
2. After inserting a Delay(20) most of the time the Gadgets are created.
A Delay(2) gives a 50:50 chance, that the Gadgeds are showing up und the program
doesn't hang.
Increasing delay time doesn't inrease stability, still sometimes the program hangs.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Fri Mar 29, 2019 4:01 am 
Offline
Enthusiast
Enthusiast

Joined: Sun Apr 06, 2008 12:54 pm
Posts: 379
Location: Brisbane, Qld, Australia
ozzie wrote:
Looks good, but the first click on one of the buttons (show password or delete) is ignored. Need to click a second time for the action to occur.

Works fine now. Many thanks - the 'show password' feature is what I'm particularly interested in. (Windows only.)

_________________
Mike
www.showcuesystems.com


Top
 Profile  
Reply with quote  
 Post subject: Re: [Module] StringEx (all OS)
PostPosted: Fri Mar 29, 2019 8:22 am 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2057
Location: Germany
UseGadgetList(0) gives the actual handle, object of GadgetList
Code:
;-TOP

DeclareModule System
  Declare WindowPB(WindowID)
  Declare GadgetPB(GadgetID)
EndDeclareModule

Module System
 
  ;-- Import internal function
 
  ; Force Import Fonts
  ;Global __Dummy = LoadFont(#PB_Any, "", 9) : FreeFont(__Dummy)
 
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    Import ""
      PB_Object_EnumerateStart( PB_Objects )
      PB_Object_EnumerateNext( PB_Objects, *ID.Integer )
      PB_Object_EnumerateAbort( PB_Objects )
      PB_Object_GetObject( PB_Object , DynamicOrArrayID)
      PB_Window_Objects.i
      PB_Gadget_Objects.i
      PB_Image_Objects.i
      ;PB_Font_Objects.i
    EndImport
  CompilerElse
    ImportC ""
      PB_Object_EnumerateStart( PB_Objects )
      PB_Object_EnumerateNext( PB_Objects, *ID.Integer )
      PB_Object_EnumerateAbort( PB_Objects )
      PB_Object_GetObject( PB_Object , DynamicOrArrayID)
      PB_Window_Objects.i
      PB_Gadget_Objects.i
      PB_Image_Objects.i
      ;PB_Font_Objects.i
    EndImport
  CompilerEndIf
 
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    ; PB Interne Struktur Gadget MacOS
    Structure sdkGadget
      *gadget
      *container
      *vt
      UserData.i
      Window.i
      Type.i
      Flags.i
    EndStructure
  CompilerEndIf
 
  ; ---------------------------------------------------------------------------------------
 
  Procedure WindowPB(WindowID) ; Find pb-id over handle
    Protected result, window
    result = -1
    PB_Object_EnumerateStart(PB_Window_Objects)
    While PB_Object_EnumerateNext(PB_Window_Objects, @window)
      If WindowID = WindowID(window)
        result = window
        Break
      EndIf
    Wend
    PB_Object_EnumerateAbort(PB_Window_Objects)
    ProcedureReturn result
  EndProcedure
 
  ; ---------------------------------------------------------------------------------------
 
  Procedure GadgetPB(GadgetID) ; Find pb-id over handle
    Protected result, gadget
    result = -1
    PB_Object_EnumerateStart(PB_Gadget_Objects)
    While PB_Object_EnumerateNext(PB_Gadget_Objects, @gadget)
      If GadgetID = GadgetID(gadget)
        result = gadget
        Break
      EndIf
    Wend
    PB_Object_EnumerateAbort(PB_Gadget_Objects)
    ProcedureReturn result
  EndProcedure
 
  ; ---------------------------------------------------------------------------------------
 
EndModule

If OpenWindow(1, 20, 20, 200, 40, "Module System")
 
  Debug "PB-WindowID = " + System::WindowPB(UseGadgetList(0))
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Break
    EndSelect
  ForEver
EndIf

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye