mos Posted February 2, 2018 Share Posted February 2, 2018 I am trying to prevent text selection highlighting of a TUniLabel which is being dynamically created in code. In the UniServerModule.CustomCSS I have the following: .noselect { -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Safari */ -khtml-user-select: none; /* Konqueror HTML */ -moz-user-select: none; /* Firefox */ -ms-user-select: none; /* Internet Explorer/Edge */ user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */ } And In code I create the label and try to set the UniEvents beforeInit: FLbl := TUniLabel.Create(Self); FLbl.Parent := Self; FLbl.Font.Size := 20; FLbl.Left := 10; FLbl.Text := 'Hello There'; FLbl.ClientEvents.UniEvents.Text := 'beforeInit=function beforeInit(sender, config)'#13#10'{'#13#10' config.cls=' + '"noselect";'#13#10'}' However the above does not work and I can still highlight the label text. I know the CSS does work if I put a TUniLabel on a form and in the object inspector set the beforeInit. What do I need to do to get the above code to work when the label is dynamically created? Link to comment Share on other sites More sharing options...
Sherzod Posted February 2, 2018 Share Posted February 2, 2018 Hi, For example: 1. CustomCSS: *.unselectable { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; } 2. FLbl := TUniLabel.Create(Self); FLbl.Parent := Self; FLbl.Font.Size := 20; FLbl.Left := 10; FLbl.Text := 'Hello There'; FLbl.JSInterface.JSCall('addCls', ['unselectable']); //<--------- Best regards, Link to comment Share on other sites More sharing options...
Luis Devis Posted January 27, 2021 Share Posted January 27, 2021 👌 😃 GREAT !!! it works veeeery well Thank you, you're the best. 1 Link to comment Share on other sites More sharing options...
rgreat Posted November 22, 2023 Share Posted November 22, 2023 Enabled:=False, no? As it does not currently change label color, it will do the same. But is not there a way to set unelectable to all labels, globally? Link to comment Share on other sites More sharing options...
rgreat Posted November 22, 2023 Share Posted November 22, 2023 Is there a way to make "loading.." frame of ScreenMask unelectable too? Link to comment Share on other sites More sharing options...
rgreat Posted November 22, 2023 Share Posted November 22, 2023 25 minutes ago, rgreat said: But is not there a way to set unelectable to all labels, globally? Done myself: .x-abs-layout-item, label { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; } Link to comment Share on other sites More sharing options...
rgreat Posted November 22, 2023 Share Posted November 22, 2023 25 minutes ago, rgreat said: Is there a way to make "loading.." frame of ScreenMask unelectable too? And again, myself: .x-mask-msg { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; } Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now