Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » RAP Selectable Label with MarkUp(Allow mouse-selection of text in Label with MarkUp)
RAP Selectable Label with MarkUp [message #1773316] Tue, 26 September 2017 12:33 Go to next message
John Gymer is currently offline John GymerFriend
Messages: 257
Registered: November 2012
Location: UK
Senior Member
Is there are way to allow the text in a Label widget (RAP/Browser) to be selectable with the mouse, so the user can use copy-to-clipboard feature in the browser? This would be similar to any other HTML element on a traditional web page.

I considered using a Text widget instead, and making it read-only, but the problem is that I really need RWT MarkUp styling, and Text does not support this (or does it?!).

Is this achievable?

Thanks, John


---
Just because you can doesn't mean you should
Re: RAP Selectable Label with MarkUp [message #1773364 is a reply to message #1773316] Tue, 26 September 2017 20:48 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 205
Registered: February 2011
Senior Member
If you can get a hold of the rwtWidget object via ClientScripting somehow, you can call setSelectable(true) on it to enable text selection.
Once the text is selected Ctrl-C copies it.
Not sure how to enable the default context menu though.
Re: RAP Selectable Label with MarkUp [message #1773388 is a reply to message #1773364] Wed, 27 September 2017 08:15 Go to previous messageGo to next message
John Gymer is currently offline John GymerFriend
Messages: 257
Registered: November 2012
Location: UK
Senior Member
Thanks Chris - seems like a hopeful idea.
I tried modifying the "user-select" style attribute in Chrome's F12 tools to "text" as an experiment, but this didn't help.
Would setSelectable(true) be changing something else?
I then tried some ClientScripting to call setSelectable(true) for the widget, but it is an unknown function... can you give me a clue how to call it please?

Error: Error in scripting event type MouseEnter: event.widget.setSelectable is not a function
    at rap-client.js:253
...


Here is the JS ClientScript that I tried:

var handleEvent = function(event) {
	switch(event.type) {
	case SWT.MouseEnter:
		event.widget.setSelectable(true);
		break;
	}
};


Thanks, John


---
Just because you can doesn't mean you should
Re: RAP Selectable Label with MarkUp [message #1773434 is a reply to message #1773388] Wed, 27 September 2017 19:41 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 205
Registered: February 2011
Senior Member
I don't know how you get to the rwt Widget from client scripting, it's internal API.
There are listeners attached to the document/body/window to handle the select events, calling setSelectable(true) stops the event being cancelled. It also updates the user-select styles that block it.
I did it by selecting the element in Chrome and referencing it with $0.rwtWidget
$0
<div style="background: rgb(255, 255, 255); bor....
$0.rwtWidget
{
   [functions]: ,
   $cells: [ ],
   $el: { },
   ___rwtStyle__backgroundColor: "rgb(255,255,255)",
....
   classname: "rwt.widgets.Label",
   name: "rwt.widgets.Label"
}
$0.rwtWidget.getSelectable()
false
$0.rwtWidget.setSelectable(true)
true


You could patch Label.js to call this.setSelectable(true); in the constructor or change the init value in the selectable property. That might have wider reaching effects though.

Perhaps you could make a custom widget based off Label, with its own LCA so you can set the selectable property from the Java side. i don't think you'd need to touch the JS side

Re: RAP Selectable Label with MarkUp [message #1773766 is a reply to message #1773434] Wed, 04 October 2017 11:23 Go to previous message
John Gymer is currently offline John GymerFriend
Messages: 257
Registered: November 2012
Location: UK
Senior Member
Hi Chris, thanks for the ideas.
However, I'm not understanding how to apply this.
It isn't just Labels in principle... in fact, users will expect that if they can see text on a web page, then they should be able to highlight it with the mouse and copy-to-clipboard, or whatever.
I'm struggling to see how this can be done, with JS, ClientScripting or anything in RAP.
The user-select attribute appears to have no effect, even when modified in Chrome's F12 as a test, so presumably it is the event listeners for the page in RAP that are preventing this. You eluded to this in your reply above, but I've no clue how to apply your suggestion to the page, particularly via code rather than messing about in Chrome's F12. It needs to work on all browsers of course.
Thanks, John




---
Just because you can doesn't mean you should
Previous Topic:[ANN] RAP 3.3 released
Next Topic:Future of RAP
Goto Forum:
  


Current Time: Wed Aug 15 12:41:09 GMT 2018

Powered by FUDForum. Page generated in 0.01903 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top