【问题标题】:How to get the properties of the `move` event from an atom electron's BrowserWindow?如何从原子电子的 BrowserWindow 中获取“move”事件的属性?
【发布时间】:2016-04-25 16:30:52
【问题描述】:

BrowserWindow 有一个move 事件,如下所述:
https://github.com/atom/electron/blob/master/docs/api/browser-window.md#event-move

但是我如何获得它移动的坐标呢?
我这样做:

mainWindow.on( "move", function( event ) {
    console.log( event );
});

但我明白了:

{ preventDefault: [Function: preventDefault],
  sender: 
   BrowserWindow {
     _events: 
      { blur: [Function],
        focus: [Function],
        'devtools-opened': [Function],
        closed: [Function],
        move: [Function] },
     _eventsCount: 5,
     devToolsWebContents: [Getter] } }

现在呢?事件的属性是什么?没有记录任何事件属性。

【问题讨论】:

    标签: node.js electron


    【解决方案1】:

    你可以像这样得到它们:

    mainWindow.on( "move", function( event ) {
        console.log( event.sender.getBounds() );
    });
    

    输出:

    Object {x: 622, y: 159, width: 800, height: 600}
    

    【讨论】:

    • 谢谢!我怎么能找到其他事件属性,是否记录在任何地方?
    • 当然。关于事件属性,就是这样......我认为大多数 BrowserWindow 事件对象没有任何属性,只需通知事件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-11
    • 1970-01-01
    • 2017-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多