Hello Team, question regarding the cursor position in the LOV component.

We have a default value (%) which we put into the search field. In the code it would be something like that: api_lov.setSearchField('AIRP', 'airp_lov1.code', '%');

After that we perform the query execution: api_datasource.executeQuery('airp_lov1');

And then we show the LOV: api_lov.show('AIRP')

The cursor position is set to be after the percent sign (%) (can't upload file because of insufficient carma).

https://yadi.sk/i/tti8WAUbpUG5m

The issue is that in the most cases people search by the first symbol and they need to perform an additional step to move the cursor before the percent sign.

Is there any way to place the cursor at the start of the input?

Thanks and best regards, Anatoly

asked 25 Feb '16, 05:27

anatoly4u's gravatar image

anatoly4u
6913
accept rate: 0%

edited 25 Feb '16, 05:28


I don't think there is a api to set the cursor position (Formspider Team correct me if I'm wrong) but it should be possible to do with a little bit of javascript.

I have a working demo of this and if there is enough interest I can put a tar file somewhere, but I'll put instructions below

Create a new application with the following xml in the mainPanel

<panel>
  <tableLayout cellSpacing="5">
    <row>
      <cell>
        <textLabel label="Field A"/>
      </cell>
      <cell>
        <textField name="curtest"/>
      </cell>
    </row>
  </tableLayout> 
</panel>

create a .js file and paste the following code into it

function setCursor(elemName, pos) {
var elem = document.getElementById(elemName);

if(elem != null) {
    if(elem.createTextRange) {
        var range = elem.createTextRange();
        range.move('character', pos);
        range.select();
    }
    else {
        if(elem.selectionStart) {
            elem.focus();
            elem.setSelectionRange(pos, pos);
        }
        else
            elem.focus();
    }
  }
}

I've put mine in the "js" subdirectory and called it cursorTest.js next edit the main.jsp page and add the following line just after it adds the fs-all.js file

<script type="text/javascript" src="js/cursorTest.js?version=1.0"></script>

Next in the formspiderIDE create a new external method with the following settings:-

Name: setCursor
JavaScript Signature: setCursor(string, number)

Leave everything else blank, hit OK

For the demo I've created a simple "init" procedure that is called when the app starts and the code is below

procedure init as
  v_params_t      api_externalMethod.tt_params;
begin

  api_component.setvalue('mainPanel.curtest','this is a test');

  v_params_t('0').value_tx := 'curtest-mainPanel';
  v_params_t('1').value_tx := 0;
  api_externalMethod.invoke('setCursor', v_params_t);
end init;

When you now run the application the cursor should be positioned at the start of the field. hope this helps Simon

link

answered 27 Feb '16, 05:09

apacheuk's gravatar image

apacheuk
139218
accept rate: 0%

edited 27 Feb '16, 05:11

thanks for the reply. though your code works only in IE - it gave a right direction for the further investigation

(29 Feb '16, 09:59) anatoly4u

definately works on the version of firefox included in the Oracle Developer VM, but I have to be honest I didn't check it in any other browsers.... glad it helped though

(29 Feb '16, 10:27) apacheuk
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×30
×6

Asked: 25 Feb '16, 05:27

Seen: 990 times

Last updated: 29 Feb '16, 10:27


© Copyright Gerger 2017