本文整理汇总了TypeScript中phosphor/lib/core/messaging.installMessageHook函数的典型用法代码示例。如果您正苦于以下问题:TypeScript installMessageHook函数的具体用法?TypeScript installMessageHook怎么用?TypeScript installMessageHook使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了installMessageHook函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: newIFrame
/**
* Create a new IFrame widget.
*
* #### Notes
* Once layout restoration is fully supported, the hidden state of the IFrame
* widget will be handled by the layout restorer and not by the message hook
* handler in this function.
*/
function newIFrame(id: string): IFrame {
let iframe = new IFrame();
iframe.addClass(HELP_CLASS);
iframe.title.label = 'Help';
iframe.id = id;
// If the help widget is being hidden, remove its state.
installMessageHook(iframe, (iframe: IFrame, msg: Message) => {
if (msg === WidgetMessage.BeforeHide) {
state.remove(key);
}
return true;
});
return iframe;
}
示例2: newIFrame
/**
* Create a new IFrame widget.
*/
function newIFrame(url: string): IFrame {
let iframe = new IFrame();
iframe.addClass(HELP_CLASS);
iframe.title.label = category;
iframe.id = `${namespace}`;
iframe.url = url;
// Add the iframe to the instance tracker.
tracker.add(iframe, { area: 'right' });
// If the help widget visibility changes, update the tracker.
installMessageHook(iframe, (iframe: IFrame, msg: Message) => {
switch (msg) {
case WidgetMessage.AfterShow:
case WidgetMessage.BeforeHide:
// Wait until hide has completed.
requestAnimationFrame(() => { tracker.save(iframe); });
break;
default:
break;
}
return true;
});
return iframe;
}