Chrome Apps: Keep An App Visible + detect when not focused - focus

Keep an app visible:
I would like for an app to be visible when the user has clicked off (not the X, but they've moved to a different window), like chromeos's music player.
Detect when not focused:
Self-explanatory
Sadly, I can't give code samples because I don't know where to start.

Add the "alwaysOnTopWindows" permission to your manifest. Then create a window like this:
chrome.app.window.create("index.html", { alwaysOnTop: true })

Related

window.addEventListener('click', function) not working on iPhone

I am currently working on Wes Bos' JavaScript 30 project, and in this drumkit project, I was hoping to add to his finished code by allowing user to click on the button rather than only through 'keydown' event.
After adding to the playSound function to detect
event.path[1].dataset.key || event.path[0].dataset.key
so that the click event would be able to grab the button's attribute, which contains the keyCode, and use that to detect which audio to play. Then I wrote this:
window.addEventListener('click', playSound);
and it worked great on desktop, it also worked great on my android smart phone, but for some reason the button doesn't work on an iphone.
So after looking through some similar results on stackoverflow, here's what I've tried:
window.addEventListener('touchstart', playSound)
and
window.addEventListener('DOMContentLoaded', (event) => {
window.addEventListener('touchstart', playSound)
});
but neither of them seems to work on iphone. Is there something special about iphone that doesn't allow me to click a button using their touch screen? Android doesn't seems to have this issue at all.
it turns out all i needed to do is use document.addEventListener instead of window.addEventListener for iOS

App crashes on return from some share plugins of activityViewController

I've got a TableViewController with static table; one of it's cells houses an UIView named graphArea. The view renders a chart, it's background and an axis line - all inside it's drawRect(). There are also two another views (sunView & markerView), that are made with Interface Builder and used for chart dynamics (moving marker line and point on touch events).
All worked buttery smooth until I've implemented and tried to test a share button, that employs the ordinary activityViewController mechanism.
The magic begins, when one from a couple of share activities, whose share plugin window takes the full screen, is finished (no matter whether sharing succeeded or cancelled). The app crashes.
Discovery using debugger made apparent to me, that the crash happens, because some views, including graphArea, sunView, markerView are nil after return from sharing screen.
Only some of fullscreen share plugins (like preinstalled Mail and Messages, or, in my case, "Download to DropBox" action) lead app to crash. Other fullscreen share plugins do not (tested Telegram, WhatsApp, Skype). No one of those non-fullscreen plugins has ever caused crash (Evernote, Twitter, 2Do etc.).
It looks like graphArea, sunView, markerView are deallocated from memory when "malicious" share plugins take full screen. I haven't figured out, why.
Here's some debug info:
The traceback and assembly of fatalErrorMessage.
The next screenshot shows a part of controller code and properties, that are nil on return from share plugin (gray selection). And yes, they were all non-nil before.
Please, help me! Thank you in advance!
Thank you, Palpatim. My friend also pointed me at the same thing: I've put graphArea.removeFromSuperview() in viewDidDisappear(), and this caused the exception after share plugins, that have .presentationStyle = fullScreen. So at the point, when the app is to show again, there is no more graphArea in on the tableView.

How to restrict Youtube player fullscreen still within the window, I don't want to have real fullscreen

I have the awesome config like this below:
{ rule = { instance = "plugin-container" },
properties = { floating = false },
callback = awful.titlebar.hide },
I don't want to have my Youtube fullscreen really playing fullscreen, but instead it is playing within the window size. If I want to have fullscreen, I could do with Win+F shortcut.
With the config above it doesn't work. Whenever I click fullscreen, it is really playing fullscreen.
I am used to be an Ion3 user and in Ion3 it just works. I am wondering whether it is possible for Awesome to do like that?
Many thanks.
You can do that on the src attribute of your iframe by adding fs=0 parameter
<iframe w src="//www.youtube.com/embed/video_id?fs=0></iframe>
Parameters doc
I know this is old but found this while asking a similar question just now. Not sure it helps you much since I think you were trying to do the same thing I am (make it a permanent feature by adding something to rc.lua), but if you click YouTube's fullscreen button or have VLC fullscreen itself or whatever and THEN Super+F you will get the effect you want. It will defullscreen into its previous window size but the client still thinks it is in fullscreen mode.
Untested
client.connect_signal("property::fullscreen", function(c) if c.instance == "plugin-container" then c.fullscreen = false end end)

Xcode/Objective-C implementing a players turn toggle

I'm new to the whole VCM programming structure and more specifically to objective-c.
Right now i'm working on an iOS app that is like the game "connect 4." This Xcode project is my practice project that i've been using to play around/learn how to make iOS apps so there are several files and lots of commented out code, so Ill try my best to provide the necessary content from my project.
App State:
Right now I have a 10x10 grid of blue square/buttons. I'm still in the early stages of implementing the functionality of the game. Rather than making each square its own button, I created 10 frames and 10 buttons. Each row is a single button, which is broken up into 10 squares.
I currently have the squares change their color to red and become disabled once clicked. If I click multiple times.. the squares turn red when pressed. Heres a screenshot example run:
What Im wanting to do:
I want to build off of what I have, but not exactly sure how to keep track of which "players turn" it is. For example.. I want the first clicked square to turn red, representing player1's move. I want the second click to turn the button, say green, representing player2's move.. then the next move will be player 1's move.
I know Ill have to make sure the button is/was ENABLED and valid before switching which players turn it is.
How should I go about doing this? This is more of a general question, but I'll provide needed code snippets if necessary. Thanks!
In your .h file add an integer (variable)
int Turn = 1;
In your .m file you can do:
if(Turn == 1)
{
// Player one is playing
Turn = 2;
}
else if(Turn == 2)
{
// Player two is playing
Turn = 1;
}

iPhone Safari keyboard to say next vs go

I have a website that is optimized to work on iOS devices. But the problem is that the keyboard always says Go as user fills the form. How do I get the keyboard to say Next until the last entry on the form, where it should say Go? Or alternatively, how do I disable the Enter button entirely?
Again, this is a website. It works everywhere websites work: in browsers. Except I have having this particular problem in Safari on mobile devices.
while changing the input type gives you some control of the keyboard layout the return key label in IOS cannot be customized.
Other than changing it to say Search there are no customizations available. You can disable the functionality of the button using something like this injQuery:
$("#myForm input").live("keyup", function(evt) {
if (evt.keyCode === 13) {
$("#myForm").trigger("submit");
}
});

Resources