[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [platform-swt-dev] Overrriding default behaviors
|
>>>>> We are trying to add editing capabilities to the Table widget. We
would
>>>>> like to simulate the Excel's cell behaviour, including the "embeded
>>>>> combo" option. The problem is some keys already have behaviour that we
>>>>> cannot override (la arrows chang the selection in the combo). We'd
like
>>>>> to allow the user to use the keys to navigate through the cells but we
>>>>> cannt avoid the combo selection to change (in the case of the up and
>>>>> down arrows).
>>>>> That default behaviour doesn't do any harm in the case of the Text
>>>>> widget, it just moves the cursor.
>>>>> So, is there any way, including subclassing or calling the OS, to
avoid
>>>>> the widget's default behavoiurs envolving the key events?
I've had the same problem, but I've fixed it with the following things:
protected boolean mCancelComboSelection;
...
combo.addTraverseListener(this);
combo.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent e)
{
if(mCancelComboSelection)
{
e.doit=false;
mCancelComboSelection=false;
}
}
public void keyTraversed(TraverseEvent e)
{
if(mEditor.getEditor() instanceof CCombo)
{
mCancelComboSelection=true;
}
e.doit=false;
}
The effect is that the combo doesn't open any longer on ARROW_UP or
ARROW_DOWN. Of course, you need to do something else instead. In my case,
the cursor goes to the cell up or the cell down (if possible).