Bug 176012 - TextActionHandler refuses work with Toolbar
Summary: TextActionHandler refuses work with Toolbar
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Windows XP
: P3 trivial with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2007-03-01 07:19 EST by Christoph Mayerhofer CLA
Modified: 2019-09-06 15:37 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Mayerhofer CLA 2007-03-01 07:19:17 EST
Build ID: M20060921-0945

Steps To Reproduce:
1. Add the Cut action to the toolbar (for me done in the ApplicationActionBarAdvisor):
   
   private IWorkbenchAction cutAction;
   ...
   cutAction = ActionFactory.CUT.create(window);
   register(cutAction);
   ...
   toolBarManager.add(cutAction);

2. register the TextActionHandler for a text widget:
   TextActionHandler textActionHandler = new TextActionHandler(this.getViewSite().getActionBars());
   textActionHandler.addText(myText);

3. Now open the application, put some text in the text widget, mark it and push the icon 'Cut' from the application toolbar. The button gets disabled and the cut-action is not done.

More information:
I'm using the TextActionHandler in a non-IDE application. The reason for the bug seams to be the following:

1) The text widget gets activated when the user typs some text in the widget.
2) The listener SWT.Deactivate is fired when the user pushes a button from the toolbar. activeTextControl gets null and the button gets deactivated.

I have modified the following code in the class TextActionHandler:

    private class TextControlListener implements Listener {
        public void handleEvent(Event event) {
            switch (event.type) {
            case SWT.Activate:
                activeTextControl = (Text) event.widget;
                updateActionsEnableState();
                break;
            case SWT.Deactivate:
                //do not set the active widget to null
                //activeTextControl = null;
                updateActionsEnableState();
                break;
            default:
                break;
            }
        }
    }

I do not know if this could solve the problem, since I haven't tested it very well.
Comment 1 Christoph Mayerhofer CLA 2007-03-01 07:51:30 EST
After investigating some time into this issue a better way would be to use the SWT.FocusIn and SWT.FocusOut events instead of the SWT.Activate and SWT.Deactivate event types. For me this leads to the desired behavior of the text cut/copy/paste handlers.
Comment 2 Eric Moffatt CLA 2007-03-13 16:05:26 EDT
Not sure if you're the right person; punt it back or pass it on...
Comment 3 Paul Webster CLA 2007-04-04 16:35:51 EDT
I'll try and look at this for RC1
PW
Comment 4 Paul Webster CLA 2007-04-26 12:10:49 EDT
No time in 3.3
PW
Comment 5 Eclipse Webmaster CLA 2019-09-06 15:37:32 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.