- 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)
Download: StringExModule.pbi
Code: Select all
String::Gadget(#StringPW, 225, 19, 100, 20, "Password", String::#Password|String::#ShowButton)
Code: Select all
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
Code: Select all
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
Then it hangs. Any ideas?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
No Change to above.Thorsten1867 wrote:
- Bugfixes
- Added: Ctrl-Cursor/ Tabulator (AutoComplete)
I can't understand the mistake because it doesn't occur to me.Lord wrote:No Change to above.
Still blank window in debug mode.
See 5 postings above. It's your code included in your module.Thorsten1867 wrote:I can't understand the mistake because it doesn't occur to me.Lord wrote:No Change to above.
Still blank window in debug mode.
Does this happen with my test code or in your own program?
No change. Tested the latest version.Thorsten1867 wrote:Maybe it's a problem with GetActiveWindow().
I have now added the window number in the example.
Works fine now. Many thanks - the 'show password' feature is what I'm particularly interested in. (Windows only.)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.
Code: Select all
;-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