Well, perhaps the StringGadget can be subclassed to prevent tabbing to it and selecting the text?Thunder93 wrote:I don't like the fact it greys out the text colour and making it very difficult to see.
[Given up to peer pressure] String Gadget ReadOnly
Re: [Given up to peer pressure] String Gadget ReadOnly
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: [Given up to peer pressure] String Gadget ReadOnly
If the StringGadget is disabled, there are no events from it. My actual work-around is to use Win Api to hold the Z-level of an Image Gadget over the StringGadget - so the string text is inaccessible and the ImageGadget() events can be used.
If you want to disable a StringGadget but don't like the greyed-out look, you can disable, then set the front and back colours!
If you want to disable a StringGadget but don't like the greyed-out look, you can disable, then set the front and back colours!
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: [Given up to peer pressure] String Gadget ReadOnly
Yes.. Setting the text colour before, or after disabling the gadget.. does nothing. It turns grey when you disable the gadget.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: [Given up to peer pressure] String Gadget ReadOnly
You are right Thunderbird93 - I'm sure that trick used to work.........
Anyhow, snippet below showing the mask method, with or without a change of colour:
Anyhow, snippet below showing the mask method, with or without a change of colour:
Code: Select all
Enumeration
#Win
#StrGdt
#ImgGdtMask
#Mask
#BtnDisable
EndEnumeration
CreateImage(#Mask, 214, 38, 32, #PB_Image_Transparent)
Procedure DisableStrGdt()
;#-----------------------
;SetGadgetColor(#StrGdt, #PB_Gadget_BackColor, RGB(228,228,228)) ;If required
HideGadget(#ImgGdtMask, #False)
SetWindowPos_(GadgetID(#ImgGdtMask), #HWND_TOP, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_FRAMECHANGED)
EndProcedure
Procedure Win()
;#-------------
If OpenWindow(#Win, 0, 0, 230, 110, "StringGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(#StrGdt, 8, 14, 214, 38, "STRING GADGET TEXT", #ES_CENTER)
ImageGadget(#ImgGdtMask, 8, 14, 214, 38, ImageID(#Mask)) : HideGadget(#ImgGdtMask, #True)
ButtonGadget(#BtnDisable, 10, 60, 212, 40, "Disable")
SetGadgetColor(#StrGdt, #PB_Gadget_FrontColor, RGB(5,5,5))
SetGadgetColor(#StrGdt, #PB_Gadget_BackColor, RGB(128,255,128))
BindGadgetEvent(#BtnDisable, @DisableStrGdt(), #PB_EventType_LeftClick)
EndIf
EndProcedure
Procedure Wait()
;#--------------
Repeat
Until WaitWindowEvent(1) = #PB_Event_CloseWindow
EndProcedure
Win()
Wait()
End
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: [Given up to peer pressure] String Gadget ReadOnly
Well that read only mode acts like it should and is typical for windows controls.IdeasVacuum wrote:In Read Only mode, the User cannot edit the text in the Gadget.
I think that mode should also:
1) Not switch the mouse cursor to the text cursor;
2) Not allow text selection (for copy to the clipboard)
I don't think PB should change something with it. You can hide mouse cursor using WinAPI (HideCaret function if I'm not wrong), there is also something to disable selection, also tab switching can be changed or disabled.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Re: [Given up to peer pressure] String Gadget ReadOnly
If you only care for Windows-specific version... It is easy to have something matching all your criteria.
Code: Select all
Global oldStringGadgetProc
Procedure.i StringGadgetProc(hWnd, uMsg, wParam, lParam)
Protected result
Select uMsg
Case #WM_CONTEXTMENU
result = 0
Default
result = CallWindowProc_(oldStringGadgetProc, hWnd, uMsg, wParam, lParam)
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,200,200,400,70,"test",#PB_Window_SystemMenu)
ButtonGadget(1,10,20,60,25,"Allow tab")
ButtonGadget(2,80,20,60,25,"Allow tab")
StringGadget(3,150,20,230,25,"Can't tab here or select this text", #PB_String_ReadOnly)
oldStringGadgetProc = SetWindowLongPtr_(GadgetID(3), #GWL_WNDPROC, @StringGadgetProc())
SetGadgetColor(3, #PB_Gadget_BackColor, RGB(255,255,255))
SetActiveGadget(1)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 3
Select EventType()
Case #PB_EventType_Focus
SetActiveGadget(1)
EndSelect
EndSelect
EndSelect
Until Event=#PB_Event_CloseWindow
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Re: [Given up to peer pressure] String Gadget ReadOnly
Nice one, Thunder93. That's the subclassing that I meant.
Re: [Given up to peer pressure] String Gadget ReadOnly
Thanks Dude
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: [Given up to peer pressure] String Gadget ReadOnly
I get the jist of it Thunderbird93, but it's not working on my machine........ both buttons have the same label, neither allows text selection. In any mode, I need an event from the StringGadget if the User clicked it (hence my code snippet above).
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: [Given up to peer pressure] String Gadget ReadOnly
The buttons are named "Allow tab" to show that you can tab to those buttons only; NOT to allow tabbing to the StringGadget.IdeasVacuum wrote:both buttons have the same label, neither allows text selection.
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: [Given up to peer pressure] String Gadget ReadOnly
Oh well, it's not applicable in my case anyway.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: [Given up to peer pressure] String Gadget ReadOnly
It was only to demonstrate how we think a Read-Only gadget like StringField should be like. Didn't realize you wanted me to include also the bells and whistles.
Code: Select all
Global oldStringGadgetProc, DisableStrGdt
Procedure.i StringGadgetProc(hWnd, uMsg, wParam, lParam)
Protected result
Select uMsg
Case #WM_CONTEXTMENU
If DisableStrGdt : result = 0 : ProcedureReturn result : EndIf
result = CallWindowProc_(oldStringGadgetProc, hWnd, uMsg, wParam, lParam)
Default
result = CallWindowProc_(oldStringGadgetProc, hWnd, uMsg, wParam, lParam)
EndSelect
ProcedureReturn result
EndProcedure
Procedure DisableStrGdt()
If Not DisableStrGdt
DisableStrGdt = 1
SetGadgetText(2, "Normal")
SetGadgetColor(3, #PB_Gadget_BackColor, RGB(128,255,128))
Else
DisableStrGdt = 0
SetGadgetText(2, "ReadOnly")
SetGadgetColor(3, #PB_Gadget_BackColor, #PB_Default)
EndIf
EndProcedure
OpenWindow(0,200,200,400,70,"test",#PB_Window_SystemMenu)
ButtonGadget(2,80,20,60,25,"ReadOnly")
StringGadget(3,150,20,230,25,"STRING GADGET TEXT", #ES_CENTER)
oldStringGadgetProc = SetWindowLongPtr_(GadgetID(3), #GWL_WNDPROC, @StringGadgetProc())
BindGadgetEvent(2, @DisableStrGdt(), #PB_EventType_LeftClick)
SetActiveGadget(2)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 3
Select EventType()
Case #PB_EventType_Focus
If DisableStrGdt
SetActiveGadget(2)
EndIf
EndSelect
EndSelect
EndSelect
Until Event=#PB_Event_CloseWindow
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley