droider Posted October 23, 2017 Share Posted October 23, 2017 Hi! Why UniEdit.SelStart property doesn't work from uniGUI Apps? What is the solution? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 23, 2017 Share Posted October 23, 2017 Hi, Which edition and build are you using ? Best regards, Quote Link to comment Share on other sites More sharing options...
droider Posted October 23, 2017 Author Share Posted October 23, 2017 FMSoft_uniGUI_Complete_Professional_0.99.96.1346. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 23, 2017 Share Posted October 23, 2017 FMSoft_uniGUI_Complete_Professional_0.99.96.1346. Why not using latest version and build ?! Quote Link to comment Share on other sites More sharing options...
M477H13U Posted November 9, 2017 Share Posted November 9, 2017 Hello Lion ! I'm using nearly last build and SelStart & SelLength is not found in class TUniEdit; any workaround please ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 9, 2017 Share Posted November 9, 2017 Hi, Ok, we will try to give you a workaround Best regards, Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 10, 2017 Share Posted November 10, 2017 Hi. A bit later I will try to give you a workaround Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 10, 2017 Share Posted November 10, 2017 Can you try this simple implementation ?!: 1. MainForm -> Script: function selectSE(id, start, end) { var input = document.getElementById(id); if ('selectionStart' in input) { input.selectionStart = start; input.selectionEnd = end; input.focus(); } else { // Internet Explorer before version 9 var inputRange = input.createTextRange(); inputRange.moveStart("character", 1); inputRange.collapse(); inputRange.moveEnd("character", 1); inputRange.select(); } } 2. How to use, for example: procedure TMainForm.UniButton1Click(Sender: TObject); begin UniSession.AddJS('selectSE('+UniEdit1.JSName+'.inputEl.id, 0, 2)'); end; Best regards, Quote Link to comment Share on other sites More sharing options...
M477H13U Posted November 10, 2017 Share Posted November 10, 2017 I tried the simple but unfortunately "selectSE is not defined" when calling it.. I put it in my Main.Script property as you told be, but it does not seems to recognize the fonction; does I have to enable something more ? Best regards, Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 10, 2017 Share Posted November 10, 2017 Hi, in MainForm -> Script: try to change to this: var selectSE = function(id, start, end) { ... or document.selectSE = function(id, start, end) { ... Quote Link to comment Share on other sites More sharing options...
M477H13U Posted November 13, 2017 Share Posted November 13, 2017 Hello Lion ! Unfortunately I still got the same issue; any idea ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 13, 2017 Share Posted November 13, 2017 Hi, Sorry, can you make a simple testcase for this?! Quote Link to comment Share on other sites More sharing options...
M477H13U Posted November 13, 2017 Share Posted November 13, 2017 I don't know why, on a minimalist testCase project, I have no issue and highlighting is working properly, but on my own project, function selectSE is never recognize .. any idea ; workaround ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 16, 2017 Share Posted November 16, 2017 Hi, I don't know why, on a minimalist testCase project, I have no issue and highlighting is working properly, but on my own project, function selectSE is never recognize .. any idea ; workaround ? Ok, try this approach: 1. MainForm -> Script: Ext.form.field.Text.prototype._selectSE = function(start, end) { var input = document.getElementById(this.inputEl.id); if ('selectionStart' in input) { input.selectionStart = start; input.selectionEnd = end; input.focus(); } else { // Internet Explorer before version 9 var inputRange = input.createTextRange(); inputRange.moveStart("character", 1); inputRange.collapse(); inputRange.moveEnd("character", 1); inputRange.select(); } } 2. Use like this: UniEdit1.JSInterface.JSCall('_selectSE', [0, 2]); Best regards, Quote Link to comment Share on other sites More sharing options...
M477H13U Posted November 27, 2017 Share Posted November 27, 2017 Hello Lion ! (: Sorry I didn't have time until now to handle this problematic! (; This solution is better because I don't have the same issue: _selectSE is always recognize, but my text is not selected neither highlighted ! This solution still work properly on my minimalist test project. Any idea or workaround why text is not selected ? Best regards, Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 27, 2017 Share Posted November 27, 2017 Hi, Can you give us part of your code ? Best regards, Quote Link to comment Share on other sites More sharing options...
M477H13U Posted December 6, 2017 Share Posted December 6, 2017 I did manage to select and highlight my text: I was launching highlight after a onButtonClick event : begin uniEdit1.Text := 'This is my TEXT to be selected'; uniEdit1.JSInterface.JSCall('_selectSE', [12, 16]); end; Apparently the first line was affecting the JS call because nothing was higlighted, so I did the same thing but directly in JS: Ext.form.field.Text.prototype._selectSE = function(text){ var input = document.getElementById(this.inputEl.id); input.value = text; start = text.search("VALEUR"); end = start + 6; if ('selectionStart' in input) { input.selectionStart = start; input.selectionEnd = end; input.focus(); input.focus(); } else { var inputRange = input.createTextRange(); inputRange.moveStart("character", 1); inputRange.collapse(); inputRange.moveEnd("character", 1); inputRange.select(); } } Calling the JS method as you told me : EFilter.JSInterface.JSCall('_selectSE', ['Ceci est la VALEUR à souligner']); Best regards, Quote Link to comment Share on other sites More sharing options...
gerhardhziegler Posted April 24, 2019 Share Posted April 24, 2019 Good evening! I would like to implement that feature for an UnimDBEdit (or UnimEdit). Are the same parameters and is the same script valid? Where do I add the function? The MainM doesnt offer a script property. Regards and thanks Quote Link to comment Share on other sites More sharing options...
bahry Posted April 25, 2019 Share Posted April 25, 2019 I use the following in UniEdit ClientEvents --> UniEvents function beforeInit(sender, config) { config.selectOnFocus=true; } and it's working as expected. Regards Quote Link to comment Share on other sites More sharing options...
gerhardhziegler Posted April 25, 2019 Share Posted April 25, 2019 6 minutes ago, bahry said: I just would like to mark (select) a part of that text I use the following in UniEdit ClientEvents --> UniEvents function beforeInit(sender, config) { config.selectOnFocus=true; } and it's working as expected. Regards Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.