【发布时间】:2014-10-06 03:01:05
【问题描述】:
我创建了一个带有自定义最小化、最大化和关闭按钮的无框架 Chrome 应用。它适用于这些按钮和可拖动区域,或上下文菜单选项,但是一旦将其最小化,您就不能再从可拖动区域或菜单中移动(拖动)它了。
悬停事件也不起作用,但这不是问题,而且似乎是 Chromium 错误。见:
- https://code.google.com/p/chromium/issues/detail?id=130496
- https://code.google.com/p/chromium/issues/detail?id=124608
我想知道是否有解决方案以便我可以继续使用无框窗口,或者我唯一能做的就是在创建窗口时从 frame: "none" 更改为 frame: "chrome" 并仅更改标题栏颜色。
我使用的是 Windows 8,我在 Chromium 38.0.2066.0 (279108) 和 Chrome 36.0.1985.143 m 中都遇到了同样的问题。
我创建了一个测试应用程序,看看它是否仍然存在相同的问题,或者它是否是应用程序的其他部分的问题并且问题仍然存在。这是用于测试的代码:
manifest.json:
{
"manifest_version": 2,
"name": "Test",
"version": "1.0.0",
"description": "...",
"icons": {
"16": "icon-16.png",
"32": "icon-32.png",
/*"48": "icon-48.png",*/
"64": "icon-64.png",
"128": "icon-128.png"
},
"app": {
"background": {
"scripts": ["background.js"],
"persistent": false
}
},
"offline_enabled": true,
"permissions": [{"fileSystem": ["write"]} ]
}
background.js:
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('test.html', {
frame: "none",
bounds: {
width: 1000,
height: 600
},
minWidth:800,
minHeight:400
});
});
test.html:
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="drag-me">DRAG ME!</div>
</body>
</html>
style.css:
html{
border:1px solid #CCC;
}
#drag-me{
width:100%;
height:100%;
background:#FF3344;
-webkit-app-region: drag;
}
#drag-me:hover{
background:#FF4455;
}
编辑:
我曾尝试在最小化窗口时删除-webkit-app-region: drag 属性,并在使用事件再次恢复或最大化窗口时将其放回原处,但这并不能解决问题。
JS:
chrome.app.window.current().onMinimized.addListener(function(e){
document.getElementById("drag-me").className="";
});
chrome.app.window.current().onRestored.addListener(function(e){
document.getElementById("drag-me").className="draggable";
});
CSS:
.draggable{
-webkit-app-region: drag;
}
有什么想法吗?谢谢!
【问题讨论】:
标签: google-chrome window draggable google-chrome-app minimize