java - Adding KeyListener to TitleAreaDialog -
i have titleareadialog tableviewer allows user select row table. problem is, content of table may change on time. implement refresh behaviour commonly found in browsers (e.g. pressing f5 content of table should refresh).
below screenshot should make scenario little clearer:
it looks there possible solution in this question, think flawed several reasons:
- the listener isn't detached (e.g if reopen dialog have 2 filters on
display) - it doen't add listener
titleareadialogorwidgetbelieve belongs architectural point of view. - i avoid manual listener-attaching/detaching (e.g. listener should disposed
titleareadialog)
long story short: proper way of adding keylistener titleareadialog (or dialog in general) without using filter mechanism described in aforementioned question?
i know question somehwhat fails in sscce department, pointers right direction highly appreciated.

adding listener key events tricky thing. want listener fired when none of contained controls has focus , want fire if child of dialog has focus.
there 2 solutions problem:
- the obvious choice: use
addfilterwhendialogcreated ,removefilterwhen dialog closed (inclose()). - create
listenerswt.keyup, add all children ofdialog. necessary event fire independent of focus control.
i prefer solution 1, since it's less clutter , swt take care of (well, except adding , removing filter). adding listener child controls nothing should do, job well.
if don't want add , remove filter each time, create subclass dialog or titleareadialog once, , reuse subclassing again.
if adding , removing filter hassle in general, i'm afraid there no easier solution.
Comments
Post a Comment