Make label text copyable

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Make label text copyable

Post by SparrowhawkMMU »

Is there any reason that SB prevents the copying of label (and hyperlink) text? Is this a Dojo feature/limitation? Can this limitation be please be removed if possible (or disabled in code)?

I use labels to display some read-only data, such as record IDs, generated UIDs, fixed status text etc. When users want to send me feature requests / bug reports, they are unable to copy the text and have to copy by sight, which is difficult for some of the longer entries

Thanks

OS X, SB 1.40
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: Make label text copyable

Post by Fred »

You can try this:

Code: Select all

Procedure RemoveNoSelectClassFromWindow(Window)
  Protected WindowObject = WindowID(Window)
  
  ; Remove the specific class which disable all mouse selection
  !$(v_windowobject.element).removeClass("sbNoSelect");
EndProcedure

OpenWindow(0, #PB_Ignore, #PB_Ignore, 300, 200, "", #PB_Window_ScreenCentered)

TextGadget(0, 10, 10, 200, 80, "Some test to select", #PB_Text_Border)

RemoveNoSelectClassFromWindow(0)
On a side note, we decided to disbale all selction to make the feel like a desktop app. Having a GUI where you can select all text within can be very messy at time
JohnJohnsonSHERMAN
Posts: 14
Joined: Mon Oct 31, 2016 1:50 pm
Location: Somewhere in this world...
Contact:

Re: Make label text copyable

Post by JohnJohnsonSHERMAN »

Another method is to set the window as background with #PB_Window_Background. It works fine ...

Code: Select all

OpenWindow(#PB_Any,0,0,200,60,"Example of selectable text", #PB_Window_Background)
TextGadget(#PB_Any,0,0,200,50,~"<font face = \"segoe ui\">You can Select this text And this <a href \"http://www.google.com\">hyperlink</a></font>")
Yes, TextGadget also supports Html :)
"It's only by continuously trying that you can finally succeed."-The Shadoks

Note : This Sherman is 100% made in France, so his default language is French... Please ̶p̶a̶r̶d̶o̶n̶a̶t̶e̶ forgive him his English ̶m̶i̶s̶t̶a̶ï̶q̶u̶e̶s̶ mistakes
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: Make label text copyable

Post by Fred »

The fact it worked was a bug :). Changed for next version
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: Make label text copyable

Post by SparrowhawkMMU »

Thanks for the info everyone.
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: Make label text copyable

Post by SparrowhawkMMU »

One suggestion perhaps: a new #PB_Gadget_TextSelectable (or whatever you want to call it) constant for Label gadgets so that this can be done at the gadget level without any JS code.
JohnJohnsonSHERMAN
Posts: 14
Joined: Mon Oct 31, 2016 1:50 pm
Location: Somewhere in this world...
Contact:

Re: Make label text copyable

Post by JohnJohnsonSHERMAN »

+1 for the option... And everyone will be happy ;)
"It's only by continuously trying that you can finally succeed."-The Shadoks

Note : This Sherman is 100% made in France, so his default language is French... Please ̶p̶a̶r̶d̶o̶n̶a̶t̶e̶ forgive him his English ̶m̶i̶s̶t̶a̶ï̶q̶u̶e̶s̶ mistakes
Post Reply