Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2005

Tip: Looking for answers? Try searching our database.

SWT Key Codes

Thread view: 
blue_energy - 13 Feb 2005 22:31 GMT
I am writing an application which requires data entry and in which
rapid navigation to particular screen areas of text entry is desired.
I'm making use of SWT for the front end.  Ideally, the user would type
ALT-<key> and the focus would be transferred to a text field within the
desired data entry area.

I have presumed that I can build some code in which a listener
intercepts the ALT-<key> event at the Shell level (before it is
transferred to the current component level) and act upon it -
transferring focus to the appropriate Text widget.  Unfortunately, all
my attempts to accomplish this have failed.  Also, all of the examples
I have found only seem to work while a component that they are tied to
has focus - rather than not being tied to a particular widget.

I'm real new to SWT - oh, and I'm not using Eclipse (if that matters).
This is my first project using SWT.  Everything else has gone
relatively smoothly.  Is there a way to accomplish this too?
blue_energy - 23 Feb 2005 20:15 GMT
Well - no-one replied to my query.  I guess that I have to presume that
this is because no-one knows the answer to it.  In the meantime I've
worked around it and I suppose that in case someone else wonders how to
do this same thing - I should let them know what I've found.

I believe that my primary misconception was the presumption that a
widget is a child object of the shell upon which it resides.  In that
case, one might expect that any event that is available to the child
widget is also available to the parent (shell).  This seems not to be
the case.

In fact, my experiments would seem to indicate that a hierarchy does
not exist after all.  That is to say - a shell seems to be on the same
level, hierarchically, as a button or any other widget.  The reason
that processor control was never transferred to my shell key listener
seems to be that, at that time, the shell was not in focus (duh - how
could the shell be in focus?).  Rather, one of the text widgets always
had focus.

This was very unexpected for me.  I haven't worked with SWT before but
I've worked in a number of other environments over the years.  Event
trapping was always available to the parent as well as the child.  Not
so in SWT, as far as I can tell.

The workaround is to place a key listener in every single widget which
might have focus and call a common handler from there, passing the
trapped Event.  This is a very clumsy way to do it, if you ask me, but
it works.

> I am writing an application which requires data entry and in which
> rapid navigation to particular screen areas of text entry is desired.
[quoted text clipped - 13 lines]
> This is my first project using SWT.  Everything else has gone
> relatively smoothly.  Is there a way to accomplish this too?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.