Interesting and typically Linux,
Set/GetClipboardText must be processed with EventLoop, otherwise the whole clipboard of Linux hangs.
Geteset with Ubuntu 20.04 and 22.04, PB v5.73 and v6.00
Code: Select all
;-TOP
Enumeration Windows
#Main
EndEnumeration
Enumeration MenuBar
#MainMenu
EndEnumeration
Enumeration MenuItems
EndEnumeration
Enumeration Gadgets
#MainEdit
#MainButtonCopy
#MainButtonPaste
EndEnumeration
Enumeration StatusBar
#MainStatusBar
EndEnumeration
Procedure UpdateWindow()
Protected dx, dy
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar)
; Resize gadgets
ResizeGadget(#MainEdit, 5, 5, dx -10, dy - 45)
ResizeGadget(#MainButtonCopy, 10, dy - 35, 120, 30)
ResizeGadget(#MainButtonPaste, dx - 130, dy - 35, 120, 30)
EndProcedure
Procedure Main()
Protected dx, dy
#MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, "Window" , #MainStyle)
; Menu
CreateMenu(#MainMenu, WindowID(#Main))
; StatusBar
CreateStatusBar(#MainStatusBar, WindowID(#Main))
AddStatusBarField(#PB_Ignore)
; Gadgets
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar)
EditorGadget(#MainEdit, 5, 5, dx -10, dy - 45)
ButtonGadget(#MainButtonCopy, 10, dy - 35, 120, 30, "Copy")
ButtonGadget(#MainButtonPaste, dx - 130, dy - 35, 120, 30, "Paste")
; Bind Events
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Menu
Select EventMenu()
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Case #PB_Menu_About
Case #PB_Menu_Preferences
Case #PB_Menu_Quit
PostEvent(#PB_Event_CloseWindow, #Main, #Null)
CompilerEndIf
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #MainEdit
Select EventType()
Case #PB_EventType_Change
;
EndSelect
Case #MainButtonCopy
Select EventType()
Case #PB_EventType_LeftClick
SetClipboardText(GetGadgetText(#MainEdit))
EndSelect
Case #MainButtonPaste
Select EventType()
Case #PB_EventType_LeftClick
AddGadgetItem(#MainEdit, -1, GetClipboardText())
EndSelect
EndSelect
EndSelect
ForEver
EndIf
EndProcedure : Main()
P.S.
From Thread it doesn't work either, so I had added Set/GetClipboard to my ThreadToGUI at some point.