Jump to content
uniGUI Discussion Forums
droider

TUniEdit SelStart

Recommended Posts

FMSoft_uniGUI_Complete_Professional_0.99.96.1346.

 

Why not using latest version and build ?!

Share this post


Link to post
Share on other sites

Hello Lion !

 

I'm using nearly last build and SelStart & SelLength is not found in class TUniEdit; any workaround please ?  :rolleyes:

Share this post


Link to post
Share on other sites

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,

Share this post


Link to post
Share on other sites

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,

Share this post


Link to post
Share on other sites

Hi,

 

in MainForm -> Script:

 

try to change to this:

var selectSE = function(id, start, end) {
...

or

document.selectSE = function(id, start, end) {
...

Share this post


Link to post
Share on other sites

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 ?  :(

Share this post


Link to post
Share on other sites

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,

Share this post


Link to post
Share on other sites

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 ?  :wacko:

 

Best regards,

Share this post


Link to post
Share on other sites

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,
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×