UIAlertController and stacked UIAlert Buttons - xcode

I have an Xcode project programmed in Swift. I have an alert variable:
I also have the actual code for when the alert appears:
When I click on the 'Yes' button, everything resets and I can play the game again.
If I want to play again and win, the alert now has stacked buttons.
How do I get rid of that and make it appear like the first time?

Don't keep adding new actions to your alert box.
Either create a new alert box, or use a flag to indicate you've already created the options, so you don't add them again.
It's turning into the vertical list ("Action Sheet") format, because it now thinks there are four entries and there's not enough room to add them horizontally. But two of them have blank labels, because it's not letting you duplicate the text, to avoid ambiguity for the end user.

Related

Drag and Drop( ctrl+drag) Problems in Xcode

There are two places within Xcode (version 13.3) where I can't drag and drop anymore.
Trying to move a file to a Group. I have tried just clicking and dragging, control-click, option-click, command-click, none work. Instead of dragging the file, the cursor just moves without the selected/highlighted file and highlights whatever file or group it is hovering over.
Trying to drag a button to a View Controller to make a connection. Instead, a popup window appears with three rows, each with corresponding icon, two lines each (title and object type): View Controller, View, Button. (I can't figure out how to capture that screen since I am already holding the control key and mouse button (track pad) but here is a photo.
Update:. All works fine when using a mouse but these two problems always exist when using the trackpad. I did discover that by pressing the Escape key, I can perform the control-drag (but not move files). I have played with the trackpad settings but have not yet been able to figure out how to get rid of that window that appears.
This popup appears whether I am holding the control, option, or command key.
What xcode version are you using, just tried
#1 is working as expected on my xcode13.0
#2 seems to be working for me too..

Processing: Creating Buttons

I'm trying to create a program that creates three buttons on the right side of the screen.
When I press a button, the entire background will change color (each button will make the background a different color). Whenever the mouse is not pressed, the background will return to white. I'm having trouble understanding how to make the three rectangles into buttons.
THIS MUST BE DONE WITHOUT A SPECIAL BUTTON METHOD/LIBRARY
You need to break your problem down into smaller pieces.
Can you create a program that just shows a single button? Don't even worry about making it interactive yet. Just show a single button at hard-coded coordinates.
Now can you detect when the user clicks in that button? Just print something to the console. Get that working perfectly before moving on.
Now can you get multiple buttons working together? Again, just print somethign to the console, and make sure it works perfectly before moving on.
Finally, can you make it so pressing each button changes the background instead of printing something to the console?
If you get stuck on a specific step, you can post a MCVE along with a specific technical question. Stack Overflow really isn't designed for general "how do I do this" type questions. It's for specific "I tried X, expected Y, but got Z instead" type questions. So please try something and post an MCVE of a specific step you're stuck on. Good luck.
Check processing's documentation for mouseClicked() and mousePressed.
The former being a method called upon a click, and the later is a boolean that is constantly updated. (So you'd check for it in your draw())
You'd then want to check the mouseX and mouseY values to see if they are in your desired button's area. (Which would be displayed on screen using rect())

LibGDX (Scene2D): Using Table with Labels to do a chat menu

I am trying to do a chat menu in my game using a Table and Labels but I can't seem to get the labels to behave the way I want them to.
By default they are drawn in the middle of the table. I added this settings to fix that but now when I add new labels they expand to fill the table, which I don't want.
After adding settings:
After adding a new label:
Note: The second message is there, it's jsut very faint. Just another bug I am having :/
Also, you may notice that the "Send" button is half off screen, trying to fix that too, but one problem at a time I guess.
By the way, the table is within a ScrollPane.

show NSUserNotification additionalActions on click

In the image above you can see two notifications on OS X. The first one is from my app and the second is from Apple's Reminders.app. In the image you can see the otherButtonTitle 'Complete' and the actionButtonTitle 'Later'.
The second notification, i.e. the one from Reminders.app behaves quite differently. It gets this little arrow pointing downwards on mouse over indicating that there are more actions when clicked. And indeed, you just need to click once on 'Later' and it will give you a couple more options to choose from.
However, I can't get the same behavior to work for my notification. I don't get the little arrow on mouse over and I don't get more options displayed from a single click on 'Later' (notification just gets dismissed). More options only get displayed when holding down the mouse button on 'Later' which is not obvious.
Am I missing something obvious here? How can I get my notification to have exactly the same as the ones from the Reminders.app?
While trying to find a solution for the same problem I found this nice explanation for the NSUserNotificationPrivate class that explains how the Reminders app does it.
https://github.com/indragiek/NSUserNotificationPrivate
If the notification type is set to "Alert", the alternateActionButtonTitles property lets you set an array of additional menu item titles to be shown in an action menu that can be accessed by hovering on the Action button and clicking on the arrow.
Once a notification is handled, the index of the action can be retrieved using the _alternateActionIndex property.
So they are using a private API. As the site's disclaimer say using any of this will result in your app being rejected from the MAS and potentially breaking if the APIs change.

How do I not show the paste bar / Clear the clipboard?

I'm writing a Silverlight+XNA game and when the user has something in their clipboard they can see less of the screen. I'd really like to be able to not show this clipbaord but I can't see any way (though it does seem to go away after some amount of time)
I've tried an empty string and Clipboard.SetText(null) but that throws an exception.
Unfortunately, there is no way to either clear the clipboard from code or influence the display of the SIP beyond setting an InputScope.
The best you can do for now is to update your design to allow for the amount of space which the SIP may use. :(
While more complicated, you could create your own text input keys as buttons, and instead of using a textbox, use buttons templated to look like textblocks, with background as you show above, and all... When the user taps the "button" that is a "textblock", you set a flag that says which textblock the keypad buttons send their numbers to.
Or, if the only spot you are sending inputs to (as it appears now that I look at your UI again), there is no need for the button template as the input space, or the flag. Just create buttons for user to tap for input, and send that input to the textblock that appears to be where your answer is. You could make the buttons whatever size you want, that way, as well, so you control how much of the screen is visible. Another thing you could do is make the buttons semi-transparent, so you could have even more background image showing.
Another thought - send the buttons all to the same event handler (except the backspace button), and have the code for that event handler look like this:
{
Button btn = sender as Button;
textblock.Text += btn.Content;
}

Resources