Jump to content

Recommended Posts

  • 3 weeks later...
Posted

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,

Posted

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,

Posted

Hi,

 

in MainForm -> Script:

 

try to change to this:

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

or

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

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

Posted

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,

  • 2 weeks later...
Posted

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,

  • 2 weeks later...
Posted

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,
 
  • 1 year later...
Posted

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

Posted

I use the following in UniEdit 

ClientEvents --> UniEvents 

function beforeInit(sender, config)
{
  config.selectOnFocus=true;
}

and it's working as expected.

 

Regards

 

 

Posted
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

 

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...