[Given up to peer pressure] String Gadget ReadOnly

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

[Given up to peer pressure] String Gadget ReadOnly

Post by IdeasVacuum »

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)
Last edited by IdeasVacuum on Fri Sep 15, 2017 11:18 pm, edited 1 time in total.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: String Gadget ReadOnly

Post by ts-soft »

IdeasVacuum wrote:1) Not switch the mouse cursor to the text cursor;
2) Not allow text selection (for copy to the clipboard)
Why? It is important to me, to select the text.

-1
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: String Gadget ReadOnly

Post by mk-soft »

Code: Select all

If OpenWindow(0, #PB_Ignore, #PB_Ignore, 300, 200 ,"Read only", #PB_Window_SystemMenu)
  TextGadget(0, 5, 5, 290, 190, "Total Read Only From Human Eyes", #PB_Text_Border)
  SetGadgetColor(0, #PB_Gadget_BackColor, $FFFFFF)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Break
    EndSelect
  ForEver
EndIf
:mrgreen:
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
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: String Gadget ReadOnly

Post by IdeasVacuum »

Hi mk-soft

Nice try, but TextGadget() does not trigger events.

Hi ts-soft (are you guys related? :D )

What you describe could be implemented as #PB_String_NoEdit. That would mean the text can be selected and copied.
#PB_String_ReadOnly should mean exactly that - you can only read it.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: String Gadget ReadOnly

Post by Kukulkan »

the User cannot edit the text in the Gadget.
1) Not switch the mouse cursor to the text cursor;
2) Not allow text selection (for copy to the clipboard)
Use a TextGadget instead of a StringGadget. It fulfills all your needs :D
said
Enthusiast
Enthusiast
Posts: 342
Joined: Thu Apr 14, 2011 6:07 pm

Re: String Gadget ReadOnly

Post by said »

-1
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: String Gadget ReadOnly

Post by Dude »

IdeasVacuum wrote: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)
DisableGadget(#StringGadget, #True) ?
IdeasVacuum wrote:#PB_String_ReadOnly should mean exactly that - you can only read it.
No, read-only means you can't write to or edit it. It doesn't mean you should only be able to literally read it with your eyes.
Kukulkan wrote:Use a TextGadget instead of a StringGadget.
This is the correct answer. A StringGadget can be switched from read-only to write-capable at any time, if the developer wishes. Disabling that capability is pointless when a TextGadget does what you want.

Also, the user may actually want to select and copy the text in a StringGadget, without editing it.

Lastly, don't forget also that PureBasic's gadgets are actually just the OS's built-in controls, so to disable it would mean PureBasic would have to add extra code to purposely do that, which in turn removes the option for the developer to further enhance that gadget with specific OS API calls.

So... I give a big -1 for this request. :)
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: String Gadget ReadOnly

Post by IdeasVacuum »

Hi Guys

Please read my remark about the TextGadget not being a suitable replacement (applies to disable gadget too), and also consider my suggestion that a new flag, #PB_String_NoEdit, could be introduced to deliver the current restriction.

As it Stands, #PB_String_ReadOnly does not have appropriate restrictions to be truly read only. If it was a traffic light, it would be amber when it should be red :mrgreen:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: String Gadget ReadOnly

Post by Kukulkan »

Nice try, but TextGadget() does not trigger events.
But what useful events are left, if you can't select and edit?

I believe the problem is that PB uses standard OS gadgets. And your wish seems not possible with the standard OS gadgets on all three OS. Thus, Fred would need to do his own string gadget. And, as Dude already mentioned, this would disable any other standard OS API calls.

Maybe you can do your own Gadget by wrapping a standard StringGadget to a container (eg ContainerGadget, FrameGadget or ScrollAreaGadget)? By this, you possibly can modify the container in a way the behavior of the gadget inside is like you want it to be? Just an untested idea...
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: String Gadget ReadOnly

Post by mk-soft »

Event for TextGadget use flag '#SS_Notify'

Code: Select all

TextGadget(0, 5, 5, 290, 190, "Total Read Only From Human Eyes", #SS_NOTIFY | #PB_Text_Border)
I don´t know this for mac or Linux
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
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: String Gadget ReadOnly

Post by Dude »

IdeasVacuum wrote:#PB_String_ReadOnly does not have appropriate restrictions to be truly read only
Yes it does. It's 100% read-only. You're simply re-defining "read only" to be what you think it should be. :wink:

Read-only has nothing to do with displaying text; it's all about preventing the changing of that text.
Opcode
Enthusiast
Enthusiast
Posts: 137
Joined: Thu Jul 18, 2013 4:58 am

Re: String Gadget ReadOnly

Post by Opcode »

-1

You can accomplish what you're looking for with a canvas and drawtext. I prefer being able to copy text in a string gadget in read-only mode, just not have it editable (which is the purpose).
IdeasVacuum
Always Here
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

Post by IdeasVacuum »

Well, I have given up on this one, bigger fish to fry.
I was not asking to remove any of the functionality that is already delivered (and clearly loved by the protesters on this post), but to enhance it (re flags suggestion) for more flexibility. :cry:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: [Given up to peer pressure] String Gadget ReadOnly

Post by Dude »

IdeasVacuum wrote:enhance it (re flags suggestion) for more flexibility
The StringGadget is a standard Windows control, so Fred can't enhance it.
IdeasVacuum wrote:1) Not switch the mouse cursor to the text cursor;
2) Not allow text selection (for copy to the clipboard)
What's wrong with disabling the StringGadget to achieve both of these?

Code: Select all

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")
DisableGadget(3,#True)

SetActiveGadget(1)

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: [Given up to peer pressure] String Gadget ReadOnly

Post by Thunder93 »

While DisableGadget() seems to be the proper fit, conveniently disabling user inputs that includes selection and copying abilities. I don't like the fact it greys out the text colour and making it very difficult to see.

It wouldn't be difficult for Fred to have support for the purposed feature. Therefore +1 for me. :twisted:
ʽʽ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
Post Reply