Does dynamic toggling of "autohideMenuBar" not work? - javascript

Electron 7.1.10, Windows 10
When my app enters full screen, I'm trying to turn off menu visibility and make it "autohide" so it can be accessed through the Alt-key. The code below does turn it off but does not enable the "reveal through Alt-key" behavior.
I've tried commenting out the mainindow.setMenuBarVisibility(); calls since maybe that is absolute: menu never to be shown, but then the menu still displays in full screen. I've also tried changing the order, so that I call mainindow.autohideMenuBar = true before setting visibility to false. No luck.
Has anyone else encountered this?
The BrowserWindow docs seem to indicate that what I am trying to do should work:
win.setMenuBarVisibility(visible) Windows Linux
visible Boolean
Sets whether the menu bar should be visible. If the menu bar is
auto-hide, users can still bring up the menu bar by pressing the
single Alt key.
if (mainindow.isFullScreen()) {
// coming out of full screen
mainindow.setMenuBarVisibility(true);
mainindow.autohideMenuBar = false
mainindow.setFullScreen(false);
} else {
// entering full screen
mainindow.setMenuBarVisibility(false);
mainindow.autohideMenuBar = true
mainindow.setFullScreen(true);
}

So setting the property does not work but using the older method setAutoHideMenuBar does – though the docs state that that is deprecated. Seems like a bug.
The Electron team is currently undergoing an initiative to convert
separate getter and setter functions in Electron to bespoke properties
with get and set functionality. During this transition period, both
the new properties and old getters and setters of these functions will
work correctly and be documented.
win.setAutoHideMenuBar(hide)
hide Boolean
Sets whether the window menu bar should hide itself automatically.
Once set the menu bar will only show when users press the single Alt
key.
If the menu bar is already visible, calling setAutoHideMenuBar(true)
won't hide it immediately.
Deprecated
if (mainWindow.isFullScreen()) {
// coming out of FS
// mainWindow.autohideMenuBar = false
mainWindow.setAutoHideMenuBar(false);
mainWindow.setMenuBarVisibility(true);
mainWindow.setFullScreen(false);
} else {
// mainWindow.autohideMenuBar = true
mainWindow.setAutoHideMenuBar(true);
mainWindow.setMenuBarVisibility(false);
mainWindow.setFullScreen(true);
}

Related

Content hide/show

my goal is to hide the content of my homepage when someone visits. onClick to begin button the content should be shown. Content should stay open when user goes to other page and comes back to homepage. But it will be hidden when user closes the window and opens up the homepage again. To achieve this goal I have put the following code but it keeps the content open even when user closes and opens the window. So please help me out.
if (! localStorage.noFirstVisit) {
// hide the element
$("#content").hide();
// check this flag for escaping this if block next time
localStorage.noFirstVisit = "1";
}
Another issue is when the content shows the design gets little messed up(by widening the divs, bringing horizontal scroll)
$(".roll-button").click(function(){
$("#content").show();
});
I would highly appreciate if you check website, suggest me fix or show me proper way to achieve this goal. url:iamicongroup.com
You can totally use sessionStorage to detect whether it is new tab(window) or not.
When you first visit this page, set sessionStorage.noFirstVisit = "1";.
After you go to another page and back, sessionStorage.noFirstVisit is still "1".
But when you close the tab or browser and open the page newly again, sessionStorage.noFirstVisit will be undefined.
Documentation is here
The documentation also provide the difference between sessionStorage and localStorage.
I would suggest reading this: Detect Close windows event by Jquery
It goes over window unloading (beforeunload), which I believe is what you're after. You can set/unset your localstorage values there based on certain criteria being met; for example:
$(window).on("beforeunload", function() {
if(localStorage.noFirstVisit = "1" {
// do something
localStorage.noFirstVisit = "[someValue]"
}
else {
// do something
localStorage.noFirstVisit = "1"
}
})
Another issue is when the content shows the design gets little messed up(by widening the divs, bringing horizontal scroll)
how about adding something like 'ng-cloak' in angular, to avoid the undesirable flicker effect caused by show/hide.
when clicking the roll-button, it prevents the divs from showing unfinished..

Xcode Instruments - UIAButton Class - Method .isEnabled() not work

I'm writing some code to test IOS app using X-code and instrument. I want to check the state of a button when it toggle on/off. I try using method .isEnabled() to check if it's on/off but it fails to determine the state. In other words, instruments always passes the line "if (mainWindow.popover().buttons()[17].isEnabled())" regardless tapping the button or not.
here's part of my code:
//Button is OFF as default
//Tap to turn it ON
mainWindow.popover().buttons()[17].tap();
//Have a short delay to ensure it changes state
target.deday(1);
//Check to see if it's ON
if (mainWindow.popover().buttons()[17].isEnabled()) {
UIALogger.logMessage("button ON");
}
...
The root cause of this issue is that the button does not return any value when it toggles ON/OFF. It should return value 0 if it's Off and 1 if it's ON. I'm working out this issue with dev team.
BTW, I also mis-understood the function .IsEnabled() as it only checks if a button is able to tap or not. The function returns false if a button is greyed out (could not be tap). Otherwise, it should return true :)

javascript property race condition

I have a phonegap project on iPhone and Android. The issue appears to be a race condition on the surface, but I don't understand how it happens. Users are able to click on a button which has a closure callback that sets a property of an object, and then clears the screen and loads the main menu. In code:
button.onclick = function (employee) {
return function () {
employee.task = "some task";
returnToMenu();
}
}(employees[i]);
After the user is back on the main menu, they can click on a button that loads a screen which displays all the users. If an employee has that task property set, additionally formatting should be done to the button for that employee.
if (employee.task)
// style the button being created for this employee
Somehow, if one clicks fast enough, the formatting is not done. If you click back (to the main menu), and reload the screen, the formatting is now done. Given the code above, I do not see how employee.task could possibly return undefined after the menu has been loaded. What's going on here?

How to autohide YUI2 Menu on blur?

I have a YAHOO.widget.Button of the type "menu". My task is simple: The menu is shown when the user clicks on the button, and is hidden when the user clicks elsewhere on the screen.
Here's my code on jsfiddle:
http://jsfiddle.net/tRssn/
What I've tried so far:
1. Setting the clicktohide property of the Menu widget to true (see above code)
and
2. Subscribe to the blur event on the Button/Menu widget and close the menu if it's visible.
Approach 1 doesn't work for some reason and approach 2 works with IE and Mozilla, but not Chrome.
Shouldn't there be an easy way to do this?
Any help appreciated!
Okay, I was able to solve this by explicitly creating a YAHOO.widget.Menu object, rendering it, and then assigning it as the menu to the YAHOO.widget.Button object.
http://jsfiddle.net/tRssn/1/
Strangely, I have to set the config for the Menu widget like this instead of at the time of the creation:
oButton.getMenu().cfg.config.clicktohide.value = true;

showSettings callback in Flex?

I am pretty new to flex, so forgive me if this is an obvious question.
Is there a way to open the Security.showSettings (flash.system.Security) with a callback? or at least to detect if it is currently open or not?
My flex application is used for streaming audio, and is normally controlled by javascript, so I keep it hidden for normal use (via absolute positioning it off the page).
When I need microphone access I need to make the flash settings dialog visible, which works fine, I move it into view and open the dialog.
When the user closes it, I need to move it back off the screen so they don't see an empty flex app sitting there after they change their settings.
thanks :)
If you do something like this, it will work in some situations:
var mic:Microphone = Microphone.getMicrophone();
mic.addEventListener(StatusEvent.STATUS, onMicStatus);
If you are just trying to use the microphone and relying on Flash to pop up the dialog to ask the user for permission, Flash will open a dialog with two buttons, Allow and Deny. When the user clicks one of the buttons the StatusEvent will fire, the dialog will close, and you can move the flex app out of the way.
If you are manually opening the settings panel (via Security.showSettings), you get the panel with Allow and Deny radio buttons, and the event will fire when the user clicks on the radio buttons, not when they close the panel, which is probably of less help to you.
Update: flex 4 solution
So when I moved to the flex 4 and started compiling my mxml with adobe's open source mxmlc compiler, the solution below no longer worked because the alert doesn't lose focus when you're in the settings anymore.
As far as I could tell I had to move to a less elegant solution where the user must click "OK" on the alert box every time they are done with the settings.
Here is the new code:
private function setup_smart_hide():void {
// Call this function whenever you make the flex app visible (or add it
// to a show_flex() function if you have such a thing set up)
alert = Alert.show('Click "OK" to continue.', 'Thanks!', Alert.OK, null, function(e:CloseEvent):void {
// calls the external javascript to hide the flex app
hide_self();
});
}
OLD: (flex 3) Got this working...
private function setup_smart_hide():void {
alert = Alert.show('Thanks');
alert.addEventListener(FocusEvent.FOCUS_IN, function(event:FocusEvent):void {
// javascript to hide the flex app
ExternalInterface.call("SB.flex.hide");
});
alert.addEventListener(FocusEvent.FOCUS_OUT, function(event:FocusEvent):void {
// javascript to show the flex app
ExternalInterface.call("SB.flex.show");
});
alert.setFocus();
}
Which is run first thing in the init() function... the only problem is (like Wesley said), the focusOut event occurs when the flex app itself loses focus as well.

Categories

Resources