Hello:
sorry if this has been asked before, is it possible to right-click a cell in a listicons and copy it with a popup menu? no need to be editable
thank you
listicons: right-click --> copy, possible?
listicons: right-click --> copy, possible?
PureBasic: Surprisingly simple, diabolically powerful
Re: listicons: right-click --> copy, possible?
Have you already taken a look into this code example from TerryHough (combined with code from RASHAD) which detects a right click onto a cell in a ListIconGadget, displays a popup menu and allows you to cut, copy, paste or edit the cell content?
Re: listicons: right-click --> copy, possible?
you want that?
Code: Select all
#Window = 0
#ListIcon = 0
#Menu = 0
#MenuItemCopy = 1
If OpenWindow(#Window, 100, 100, 300, 100, "ListIconGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(#ListIcon, 5, 5, 290, 90, "Nom", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(#ListIcon, 1, "Adresse", 250)
AddGadgetItem(#ListIcon, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(#ListIcon, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
CreatePopupMenu(#Menu)
MenuItem(#MenuItemCopy,"Copy")
Repeat
Evenement = WaitWindowEvent()
Select Evenement
Case #PB_Event_Gadget
Select EventGadget()
Case #ListIcon
Select EventType()
Case #PB_EventType_RightClick
DisplayPopupMenu(#Menu,WindowID(#Window))
EndSelect
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case #MenuItemCopy
SetClipboardText(GetGadgetItemText(#ListIcon,GetGadgetState(#ListIcon)))
EndSelect
EndSelect
Until Evenement = #PB_Event_CloseWindow
EndIf
interested in Cybersecurity..
Re: listicons: right-click --> copy, possible?
with multiselection
Code: Select all
#Window = 0
#ListIcon = 0
#Menu = 0
#MenuItemCopy = 1
If OpenWindow(#Window, 100, 100, 600, 300, "ListIconGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(#ListIcon, 5, 5, 590, 290, "Num", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_MultiSelect)
AddGadgetColumn(#ListIcon, 1, "Inf0", 450)
For i = 1 To 20
AddGadgetItem(#ListIcon, -1, Str(i)+#LF$+"Info " + Str(i))
Next
CreatePopupMenu(#Menu)
MenuItem(#MenuItemCopy,"Copy")
Repeat
Evenement = WaitWindowEvent()
Select Evenement
Case #PB_Event_Gadget
Select EventGadget()
Case #ListIcon
Select EventType()
Case #PB_EventType_RightClick
DisplayPopupMenu(#Menu,WindowID(#Window))
EndSelect
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case #MenuItemCopy
cnt = CountGadgetItems(#ListIcon) - 1
col = GetGadgetAttribute(#ListIcon, #PB_ListIcon_ColumnCount) - 1
text.s = ""
For i = 0 To cnt
If GetGadgetItemState(#ListIcon, i)
For n = 0 To col
text + GetGadgetItemText(#ListIcon, i, n)
If n < col
text + #TAB$
EndIf
Next
If n < cnt
text + #CRLF$
EndIf
EndIf
Next
Debug text
SetClipboardText(text)
EndSelect
EndSelect
Until Evenement = #PB_Event_CloseWindow
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: listicons: right-click --> copy, possible?
Thanks all
In fact i want to copy a single cell, not the entire line, I'll dig in Shardik'suggestion.
In fact i want to copy a single cell, not the entire line, I'll dig in Shardik'suggestion.
PureBasic: Surprisingly simple, diabolically powerful
Re: listicons: right-click --> copy, possible?
Simple and straight forward
Code: Select all
LoadFont(0,"Tahoma",16)
OpenWindow(0,0,0,640,480,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
ListIconGadget(0,10,10,620,460,"",0,#PB_ListIcon_GridLines)
gx = GadgetX(0) : gy = GadgetY(0)
SetGadgetFont(0,FontID(0))
AddGadgetColumn(0,1,"Column 1",210)
AddGadgetColumn(0,2,"Column 2",200)
AddGadgetColumn(0,3,"Column 3",200)
For i = 1 To 16
linestr.s = LSet(Str(i),3," ")
AddGadgetItem(0, -1, Chr(10)+"Text on Line "+linestr+" in Column 1"+Chr(10)+"Text on Line "+linestr+" in Column 2"+Chr(10)+"Text on Line "+linestr+" in Column 3")
Next
CreatePopupMenu(0)
MenuItem(1, "Cut")
MenuItem(2, "Copy")
MenuItem(3, "Paste")
MenuItem(4, "Edit")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
Case #PB_Event_RightClick
Case #PB_Event_Menu
Select EventMenu()
Case 1
Case 2
SetGadgetItemColor(0,Row,#PB_Gadget_FrontColor,$0 ,Col)
SetGadgetItemColor(0,Row, #PB_Gadget_BackColor,$FFFFFF,Col)
Debug GetGadgetItemText(0,row,col)
Case 3
Case 4
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case 0
Select EventType()
Case #PB_EventType_RightClick
pInfo.LVHITTESTINFO
pInfo\pt\x = WindowMouseX(0)-gx : pInfo\pt\y = WindowMouseY(0)-gy
SendMessage_(GadgetID(0),#LVM_SUBITEMHITTEST,0,@pInfo)
row = pInfo\iItem : col = pInfo\iSubItem
SetGadgetItemColor(0,Row,#PB_Gadget_FrontColor,$FFFFFF ,Col)
SetGadgetItemColor(0,Row, #PB_Gadget_BackColor,$FF9933,Col)
DisplayPopupMenu(0, WindowID(0))
EndSelect
EndSelect
EndSelect
ForEver
Egypt my love
Re: listicons: right-click --> copy, possible?
Thank you Rashad
Really simple and awesome as always
Really simple and awesome as always
PureBasic: Surprisingly simple, diabolically powerful