Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

controlling <tab> cursor displacement

Posted on 1999-06-25
33
Medium Priority
?
395 Views
Last Modified: 2013-12-18
How to control the cursor displacement in a form when using <tab> to reach the next field?
0
Comment
Question by:onb294
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 12
  • 7
  • +1
33 Comments
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119557
The order in Notes is always left to right, top to bottom. You can have a field as the default by checking the 'give this field default focus' and the order will follow from that field.  Other ways exist but they involve the use of scripts. u would have to put code in the field exit event of each field to go to the next desired field upon exit, using this function 'uidoc.gotofield'.  For fields in layout regions also u can select fields in the order u like and as u do so, click on design-bring to front on ech field.
0
 
LVL 3

Expert Comment

by:MW
ID: 1119558
Script alone won't do it. You get in conflict with mouse events. You would need to create/use an LSX which provides functions to control/monitor keyboard events. Means what was the last pressed key when exiting a field. A goto field type of functionality without knowing what a user intended to do will drive a user nuts.
0
 

Author Comment

by:onb294
ID: 1119559
I don't know if it is essential, but the version I use is 4.5.5.

I don't accept the first part of your answer (right then down)  because the cursor jumps from a section to another without visiting all the fields of the current section.
I feel the default order could be the fields creation sequence (I'm not sure but...)

Focusing on a "default field" is OK for the first field, but
a) I can't understand this feature is available for every field even when another is already choosen
b) this doesn't solve my problem for the other fields

I don't accept the use of uidoc.gotofield feature in "exiting"  subroutine because this function is also executed when using the mouse... and the cursor doesn't go to the clicked field (but the to the one designed in the script)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Expert Comment

by:MW
ID: 1119560
You experience the little hickups in the Notes field sequence logic. Although ghassan99 was right in what he stated, Notes doesn't follow always its own rules. This can be monitored specifically in tables and sections.
0
 

Author Comment

by:onb294
ID: 1119561
A pragmatic solution?
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119562
As for the first part of the answer, there is no argue about it!  The sequence is left to righ, top to bottom!  It has nothing to do with the sequence of creation!!!  If its nor working for u, then check which fields its bypassing, if they are for instance in a layout region u can try the proposal for the layout regions.  And for the next part, yes u r right!  Of course this will conflict mouse clicks!  This is the only way possible for tab ordering around, if MW can provide u with a solution in LSX it would be probably better for u.
0
 
LVL 3

Expert Comment

by:MW
ID: 1119563
Sorry, no solution here. I just know that there are LSC based solution out there doing this sort of stuff. Maybe a research on the WEB...
0
 

Author Comment

by:onb294
ID: 1119564
What's an LSX? Only half a page in "Using Lotus Notes and Domino" (French translation - Macmillan) about it!
0
 
LVL 3

Expert Comment

by:MW
ID: 1119565
Its (like) a DLL which provides functions e.g. written in C (C++) which give for example access to the windows core functionality. Notes does deliver some of this stuff like  ODBCLSX. But you need an indept knowledge about Lotus Script before you should go into this. I'm scripting for almost four years and I'm still in a learning phase using LSX.
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119566
LSX is LotusScript EXtension. It is a DLL (shared library) of LS classes, it is written in C++.
0
 

Author Comment

by:onb294
ID: 1119567
Isn't it possible to intercept that the last key pressed is <tab>? (how?) So the "exiting" script could include a conditional execution of the 'uidoc.gotofield' function proposed by ghassan99.
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119568
What u can do is check the current string in the field that is about to be exited.  When u click on tab, the tab will actually be part of the string, so if it was found there u can capture it, and based on it decide to jump or not, here is a quick code I came up with:
     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Set uidoc = workspace.CurrentDocument
     str1 = uidoc.FIELDGETTEXT("task") 'name of the current field
     str2 = Chr$(13) 'put in here the ascii number for tab, this is for newline (I dont have the table next to me)
     If Instr(str1,str2) = 0 Then uidoc.gotofield ("priority") 'if newline is not found in the string then goto the next field, u have to put an extra check on the field itself if it was empty, so u wont test for instr = 0 coz it will be equal to 0 also if the 1st string is empty.
Try this and see.

0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119569
I tried it with the tab, it doesnt seem to work! It works with the enter key!
0
 

Author Comment

by:onb294
ID: 1119570
Sorry ghassan99, but it does not work.
Sure you cogitated a lot on this issue and I appreciate, but I've not the solution I'm searching for!
The <tab> was not stored in the string at all.
We tested by extracting the last character, and it was the last visible character, i.e. a letter.

No function available to see/handle the content of the buffer?
0
 
LVL 3

Accepted Solution

by:
MW earned 680 total points
ID: 1119571
OK kids, I did some experiments with a windows DLL. I would post the complete coding for TAB controlling on fields. But I would like to have some more points on this one.
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119572
yeah, sorry u r right, it was something of my head, when I tried it, it didnt really work.  The idea is really simple, u have to use a function in the user32.dll an API function call that will allow u to capture the last key press...I would look it up for u, but seems that MW has found one.  Good Luck
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119573
Ok onb, this time I cant be wrong!
Go to the Globals section of your form, then in the events section choose Declarations.  Then insert this inside:
Declare Function GetAsyncKeyState Lib "user32" (Byval vKey As Long) As Integer
Go to the exiting event of your field and put this in:
Sub Exiting(Source As Field)
     If (GetAsyncKeyState(9)) Then
          Messagebox "It really works!!!"
     End If
End Sub
This API funtion checks for the entry of the tab (ascii code 9), if it was hit it will return 1 (true) otherwise it will return 0.
Thank you for making me dig this out! u dont have to increase the points!;)
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119574
BTW, if u want to check for 'ESC' use ascii code 27 (&H1B)
0
 
LVL 3

Expert Comment

by:MW
ID: 1119575
OK, I decided to just post the solution. I leave it up to you, if you want to reward ghassan99, me o rmaybe even to increase points....

If you experience any problems, I could also provide a demo. In this case post your email address.


' ============================================
' in the global declaration section of the
' form:

(Declarations)
Declare Function GetKeyState Lib "User32.dll" Alias "GetKeyState" ( Byval AsciiCode As Long ) As Integer

Dim uidoc  As NotesUIDocument
Dim gtabto As String

' ============================================
' In the post open event of the form set the
' ui-document (uidoc) and gtabto variables:

Sub Postopen(Source As Notesuidocument)
     Set uidoc = source    
     gtabto    = ""
End Sub

' ============================================
' Declare the following sub at a global level:

Sub HandleTAB(tabto As String, shtabto As String)
     If gtabto <> "" Then
          gtabto = ""
     Elseif GetKeyState( 9 ) < 0 Then
          gtabto = tabto
          Call uidoc.GotoField(tabto)
     Elseif GetKeyState( 16 ) < 0 Then
          gtabto = shtabto
          Call uidoc.GotoField(shtabto)
     End If
End Sub

' ============================================
' In the fields' exiting events:

Sub Exiting(Source As Field)
     Call HandleTAB("NextField","PreviousField")
End Sub


Be aware!!!!!!

This solution might have timing problems. If you have any other coding in the exiting events the user might have released the TAB / SH-TAB key before HandleTAB is being executed.
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119576
The function getkeystate will not work, coz it will not remove the key pressed from the buffer.  It will still cause problems with mouse clicks!!!  
0
 
LVL 3

Expert Comment

by:MW
ID: 1119577
Hi ghassan,

you're wrong. Try it out or give me your email address and I send you a working! demo :-)

0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119578
Ok, try this...make a field tab-exit to a field way down, then click with the mouse on that field again, now click with the mouse in any field other than the one in the exit event, and the cursor will go to the one in the event.
0
 
LVL 3

Expert Comment

by:MW
ID: 1119579
Hi ghassan, although I'm not sure that I did your steps as you wanted me to do. Simply because you're not very clear...

...make a field tab-exit to a field way down, then click with the mouse on that field again... (again? you didn't mentioned any mouse clicks so far!)

I tried any possible combination and I can't produce any wrong behaviour of the mouse. Maybe you can tell me your steps one by one.

On the other hand, did you created the problem with my code?
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119580
I didnt try your code MW to create a problem with it, simply I know the difference between the GetKeyState and the GetAsyncKeyState, I suggest u read about that. And what I'm asking u to try is real simple, when u r in a field(x) use the tab to go to the next field(y), now with the mouse, click on the first field(x) again (follow so far?).  Next with the mouse again, click on any other field(z) (other than the one specified in the exit event) and the cursor would not jump to that field, it will jump to the field(y) in the exit event. Why? because GetKeyState determines the state of a specified key at the time the most recent input message for that key was processed.
0
 
LVL 3

Expert Comment

by:MW
ID: 1119581
I know the difference between the two functions. I have chosen GetKeyState, as it gives less timing problems then  GetAsyncKeyState. That's why I was asking you to try my example!!! It is working also for your testing procedure, as it takes care for the problem you describe.

Pls. post your email and I send you a demo. It will convince you that I'm right. It is not fair to state that a code is not working while refusing to test it!!!!!
0
 
LVL 3

Expert Comment

by:DFI
ID: 1119582
Hi!
I'm actually not an expert (I had to register so to post the message). I have to test his development from a user point of view.
He is currently off till monday. He will test your suggestions, then reward who deserves it.

Regards,

DFI
0
 
LVL 3

Expert Comment

by:MW
ID: 1119583
I know the difference between the two functions. I have chosen GetKeyState, as it gives less timing problems then  GetAsyncKeyState. That's why I was asking you to try my example!!! It is working also for your testing procedure, as it takes care for the problem you describe.

Pls. post your email and I send you a demo. It will convince you that I'm right. It is not fair to state that a code is not working while refusing to test it!!!!!
0
 
LVL 3

Expert Comment

by:DFI
ID: 1119584
Sorry to be unclear in previous comment
[... his development...], [he is ...]
I'm speaking about my colleague onb...
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 1119585
Allright MW, no problem man...why not just leave it for onb to decide.  Cheers.
0
 

Author Comment

by:onb294
ID: 1119586
MW, ghassan99,
Many thanks for your searches,

MW, would you send me the complete coding for TAB controlling on fields ?  Are you ok to send me the demo for 170 points ?

Cedric.Dehu@francemel.com

(I accept the proposed answer just after you say me if 170 points is enough)
0
 
LVL 3

Expert Comment

by:MW
ID: 1119587
Fine with me. The demo will follow within minutes!
0
 

Author Comment

by:onb294
ID: 1119588
Thank you MW !

SpecTruM   (:=D
0
 
LVL 3

Expert Comment

by:MW
ID: 1119589
For those who try the coding, here a minor correction in the HandleTAB subroutine:

Sub HandleTAB(tabto As String, shtabto As String)
     If gtabto <> "" Then
          gtabto = ""
     Elseif GetKeyState( 16 ) < 0 Then
          If shtabto = "" Then
               shtabto = uidoc.CurrentField
          End If
          gtabto = shtabto
          Call uidoc.GotoField(shtabto)
     Elseif GetKeyState( 9 ) < 0 Then
          If tabto = "" Then
               tabto = uidoc.CurrentField
          End If
          gtabto = tabto
          Call uidoc.GotoField(tabto)
     End If
End Sub
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question