mirror of
https://github.com/responsively-org/responsively-app
synced 2024-11-10 14:54:12 +00:00
Context menu added for devices
This commit is contained in:
parent
e37fa1725b
commit
0249d60892
3 changed files with 92 additions and 12 deletions
|
@ -33,6 +33,10 @@ const MESSAGE_TYPES = {
|
|||
click: 'click',
|
||||
openDevToolsInspector: 'openDevToolsInspector',
|
||||
disableInspector: 'disableInspector',
|
||||
openConsole: 'openConsole',
|
||||
tiltDevice: 'tiltDevice',
|
||||
takeScreenshot: 'takeScreenshot',
|
||||
toggleEventMirroring: 'toggleEventMirroring',
|
||||
};
|
||||
|
||||
class WebView extends Component {
|
||||
|
@ -244,7 +248,7 @@ class WebView extends Component {
|
|||
};
|
||||
|
||||
messageHandler = ({channel: type, args: [message]}) => {
|
||||
if (this.state.isUnplugged) {
|
||||
if (type !== MESSAGE_TYPES.toggleEventMirroring && this.state.isUnplugged) {
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
|
@ -260,6 +264,18 @@ class WebView extends Component {
|
|||
case MESSAGE_TYPES.disableInspector:
|
||||
this.transmitDisableInspectorToAllDevices(message);
|
||||
return;
|
||||
case MESSAGE_TYPES.openConsole:
|
||||
this._toggleDevTools();
|
||||
return;
|
||||
case MESSAGE_TYPES.tiltDevice:
|
||||
this._flipOrientation();
|
||||
return;
|
||||
case MESSAGE_TYPES.takeScreenshot:
|
||||
this.processScreenshotEvent({});
|
||||
return;
|
||||
case MESSAGE_TYPES.toggleEventMirroring:
|
||||
this._unPlug();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -350,7 +366,12 @@ class WebView extends Component {
|
|||
};
|
||||
|
||||
_unPlug = () => {
|
||||
this.setState({isUnplugged: !this.state.isUnplugged});
|
||||
this.setState({isUnplugged: !this.state.isUnplugged}, () => {
|
||||
this.webviewRef.current.send(
|
||||
'eventsMirroringState',
|
||||
!this.state.isUnplugged
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
get isMobile() {
|
||||
|
|
|
@ -5,23 +5,64 @@ const Menu = remote.Menu;
|
|||
const MenuItem = remote.MenuItem;
|
||||
|
||||
var menu = new Menu();
|
||||
var rightClickPosition = null;
|
||||
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: 'MenuItem1',
|
||||
click: function() {
|
||||
console.log('item 1 clicked');
|
||||
label: 'Take Screenshot',
|
||||
click: function(menuItem, browserWindow, event) {
|
||||
window.responsivelyApp.sendMessageToHost('takeScreenshot');
|
||||
},
|
||||
})
|
||||
);
|
||||
menu.append(new MenuItem({type: 'separator'}));
|
||||
menu.append(
|
||||
new MenuItem({label: 'MenuItem2', type: 'checkbox', checked: true})
|
||||
new MenuItem({
|
||||
label: 'Tilt Device',
|
||||
click: function(menuItem, browserWindow, event) {
|
||||
window.responsivelyApp.sendMessageToHost('tiltDevice');
|
||||
},
|
||||
})
|
||||
);
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
id: 'mirror-events',
|
||||
label: 'Mirror Events',
|
||||
type: 'checkbox',
|
||||
checked: true,
|
||||
click: function(menuItem, browserWindow, event) {
|
||||
console.log('Event mirror clicked');
|
||||
window.responsivelyApp.sendMessageToHost('toggleEventMirroring');
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
menu.append(new MenuItem({type: 'separator'}));
|
||||
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: 'Inspect',
|
||||
click: function(menuItem, browserWindow, event) {
|
||||
window.responsivelyApp.sendMessageToHost(
|
||||
'openDevToolsInspector',
|
||||
rightClickPosition
|
||||
);
|
||||
},
|
||||
})
|
||||
);
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: 'Open console',
|
||||
click: function(menuItem, browserWindow, event) {
|
||||
window.responsivelyApp.sendMessageToHost('openConsole');
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
window.addEventListener(
|
||||
'contextmenu',
|
||||
function(e) {
|
||||
e.preventDefault();
|
||||
rightClickPosition = {x: e.x, y: e.y};
|
||||
menu.popup(remote.getCurrentWindow());
|
||||
},
|
||||
false
|
||||
|
@ -130,3 +171,8 @@ ipcRenderer.on('disableInspectorMessage', (event, args) => {
|
|||
window.responsivelyApp.domInspector = null;
|
||||
window.responsivelyApp.domInspectorEnabled = false;
|
||||
});
|
||||
|
||||
ipcRenderer.on('eventsMirroringState', (event, args) => {
|
||||
console.log('eventsMirroringState', event, args);
|
||||
menu.getMenuItemById('mirror-events').checked = args;
|
||||
});
|
||||
|
|
|
@ -5220,6 +5220,14 @@ electron-settings@^3.2.0:
|
|||
clone "^2.1.1"
|
||||
jsonfile "^4.0.0"
|
||||
|
||||
electron-simple-updater@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/electron-simple-updater/-/electron-simple-updater-1.5.0.tgz#c69e13e5a25fbc189203a92bee169c41cf190782"
|
||||
integrity sha512-aT5VxKtgm76SlfaUKNA/a7xnTEsQCsz9w0m6gm36h0LqLpx0UcCpD+ktNzyqO6544SpTWw2DNENfIroPt6yfag==
|
||||
dependencies:
|
||||
httpreq "0.4.24"
|
||||
semver "*"
|
||||
|
||||
electron-to-chromium@^1.3.47, electron-to-chromium@^1.3.82:
|
||||
version "1.3.82"
|
||||
resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.82.tgz#7d13ae4437d2a783de3f4efba96b186c540b67b1"
|
||||
|
@ -7131,6 +7139,11 @@ http-signature@~1.2.0:
|
|||
jsprim "^1.2.2"
|
||||
sshpk "^1.7.0"
|
||||
|
||||
httpreq@0.4.24:
|
||||
version "0.4.24"
|
||||
resolved "https://registry.yarnpkg.com/httpreq/-/httpreq-0.4.24.tgz#4335ffd82cd969668a39465c929ac61d6393627f"
|
||||
integrity sha1-QzX/2CzZaWaKOUZckprGHWOTYn8=
|
||||
|
||||
https-browserify@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
|
||||
|
@ -12092,6 +12105,11 @@ semver-diff@^2.0.0:
|
|||
dependencies:
|
||||
semver "^5.0.3"
|
||||
|
||||
semver@*, semver@^6.2.0, semver@^6.3.0:
|
||||
version "6.3.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||
|
||||
"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
|
||||
version "5.6.0"
|
||||
resolved "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
|
||||
|
@ -12100,11 +12118,6 @@ semver@5.5.0:
|
|||
version "5.5.0"
|
||||
resolved "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
|
||||
|
||||
semver@^6.2.0, semver@^6.3.0:
|
||||
version "6.3.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||
|
||||
semver@~5.3.0:
|
||||
version "5.3.0"
|
||||
resolved "http://registry.npmjs.org/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f"
|
||||
|
|
Loading…
Reference in a new issue