开发者

OleControlSite eating key events

I'm working on an Eclipse RCP plugin that contains a View. This View contains an OleControlSite that hosts an Excel workbook.

The Excel workbook is added to the view with code along the lines of:

    public void createPartControl(Composite parent) {
        :
        OleFrame oleFrame = new OleFrame(parent, SWT.NONE);
        OleControlSite oleSite = new OleControlSite(frame, SWT.NONE, "Excel.Sheet");
        oleSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
        :
    }

What I'd like to be able to do is respond to an Eclipse key binding while the Excel workbook has the focus. The intent is to pop up a "helper" dialog that assists the user in choosing an appropriate value for the currently selected cell in the spreadsheet.

The problem I've run into is that Excel is chewing up key events (as you'd expect), but is then swallowing them as well; they never make their way to the Eclipse workbench so that I can hear about them.

I'm successfully registered for and received a variety of Excel events, through OLE, over the course of development. The events I have at my disposal through that mechanism, though, are all "Excel-specific" things like "sheet activated," "sheet changed," "sheet selection change开发者_运维问答d," those sorts of things.

:
String WORKBOOK_EVENT_SINK_ID   = "{00024412-0000-0000-C000-000000000046}";
int    WORKBOOK_SHEET_CHANGE_ID = 0x0000061c;

oleSite.addEventListener(controlSiteAuto, WORKBOOK_EVENT_SINK_ID, WORKBOOK_SHEET_CHANGE_ID, myListener);
:

There doesn't seem to be a way to register for raw key events.

While spit-balling possible ways to "hear" key events while Excel has the focus, I've tried adding filters, listeners, and key listeners to things like the default Display, the active Shell, the View itself, and so on, but with no joy. It feels like Excel is getting absolute-first-crack at key events.

I'm starting to ponder the possibility of shenanigans, like injecting a macro into the Excel workbook that would keep an eye out for keystrokes of interest, and would respond by generating an event that I could register for through the OleControlSite. It feels like maybe I'm venturing beyond the realm of good common sense when I think thoughts like these...

If anyone has any notions, I'd be thrilled to hear about them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜