user-input

XCode 4 console won't take user input

安稳与你 提交于 2019-11-30 16:00:51
问题 In XCode 4, when I run something like this: string input; cout << "Enter command" << endl; getline(cin, input); cout << "You entered: " << input << endl; I see my "Enter command" prompt in the console. But when I place my mouse cursor below it and start typing the cursor doesn't move, and my keystrokes don't show up. It basically behaves like a read-only text box. What am I doing wrong? How can I interact with my program as if it were running in the terminal? 回答1: Are you pressing Return or

XCode 4 console won't take user input

早过忘川 提交于 2019-11-30 15:51:25
In XCode 4, when I run something like this: string input; cout << "Enter command" << endl; getline(cin, input); cout << "You entered: " << input << endl; I see my "Enter command" prompt in the console. But when I place my mouse cursor below it and start typing the cursor doesn't move, and my keystrokes don't show up. It basically behaves like a read-only text box. What am I doing wrong? How can I interact with my program as if it were running in the terminal? Are you pressing Return or Enter at the end of your input line? For some keyboard the enter and return are on the same button, but if

JOptionPane Input to int

泄露秘密 提交于 2019-11-30 13:28:30
I am trying to make a JOptionPane get an input and assign it to an int but I am getting some problems with the variable types. I am trying something like this: Int ans = (Integer) JOptionPane.showInputDialog(frame, "Text", JOptionPane.INFORMATION_MESSAGE, null, null, "[sample text to help input]"); But I am getting: Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer Which sounds logical yet, I cannot think of another way to make this happen. Thanks in advance Simply use: int ans = Integer.parseInt( JOptionPane.showInputDialog(frame,

Opening a Dialog with text input from within a View in Android

╄→гoц情女王★ 提交于 2019-11-30 12:22:38
问题 I have an app with a View based on the SurfaceHolder (similar to the Lunar Lander tutorial). The whole GUI is drawn on a canvas, and I want to be able to prompt for user text input at a given moment using a custom layout Dialog, that is then taken care of and rendered to the canvas using standard procedure. My problem, however, is that it seems that best practice is to open Dialogs from the Activity. This is no problem either, since i thought i might create a Handler and then pass it to the

Use Javascript to change which submit is activated on enter key press

荒凉一梦 提交于 2019-11-30 11:02:06
I have a form on an HTML page with multiple submit buttons that perform different actions. However, when the user is typing a value into a text input and hit enters, the browsers generally act as though the next submit button sequentially was activated. I want a particular action to occur, so one solution I found was to put in invisible submit buttons into the HTML directly after the text inputs in question, like this: <input type="text" name="something" value="blah"/> <input type=submit name="desired" value="Save Earth" style="display: none"/> ... <input type=submit name="something_else"

How do I drop a pin with MapKit?

℡╲_俬逩灬. 提交于 2019-11-30 10:40:04
问题 I would like to allow the user of my app to pick a location in the map. The native map has a "drop pin" feature where you can locate something by dropping a pin. How can I do this in MapKit? 回答1: You need to create an object that implements the MKAnnotation protocol and then add that object to the MKMapView : @interface AnnotationDelegate : NSObject <MKAnnotation> { CLLocationCoordinate2D coordinate; NSString * title; NSString * subtitle; } Instantiate your delegate object and add it to the

Python: How do I get user input in the middle of a sentence (fill-in-the-blank style) using the input function?

て烟熏妆下的殇ゞ 提交于 2019-11-30 09:45:47
问题 I am trying to create a program that calculates sales tax. I first ask the user what was the total cost of their meal. I then ask them what is the sales tax of their area in the form of: y = input('What is the sales tax of your area? ') I want to have a percent sign "%" at the end of the question so that the users sees the question as: What is the sales tax of your area?_% , where the user can enter a number between the question and the percent sign (denoted by the underline). This is what I

How to make string input in Assembly language?

可紊 提交于 2019-11-30 09:37:24
Please, does anybody know how to code string input in assembly language? I'm using int 21 to display and input characters. You can use function 0Ah to read buffered input. Given a string buffer in ds:dx it reads a string of up to length 255. The buffer layout is: Byte 0 String length (0-255) Byte 1 Bytes read (0-255, filled by DOS on return) Bytes 2-..Length+2 (The character string including newline as read by DOS). An example of a small COM file that reads a string and then echos it back to the user: org 0x100 start: push cs pop ds ; COM file, ds = cs mov ah, 0x0A ; Function 0Ah Buffered

How can I use powershell's read-host function to accept a password for an external service?

邮差的信 提交于 2019-11-30 08:16:19
I have a script I'm writing that makes a connection to a SOAP service. After the connection is made, I need to pass in a the username/pass with every command I send. The problem I have is that when I use read-host to do this, my password is shown in cleartext and remains in the shell: PS C:\Users\Egr> Read-Host "Enter Pass" Enter Pass: MyPassword MyPassword If I hide it with -AsSecureString, the value can no longer be passed to the service because it is now a System.Security.SecureString object: PS C:\Users\gross> Read-Host "Enter Pass" -AsSecureString Enter Pass: ********** System.Security

Lua - get command line input from user?

隐身守侯 提交于 2019-11-30 07:09:35
问题 In my lua program, i want to stop and ask user for confirmation before proceeding with an operation. I'm not sure how to stop and wait for user input, how can it be done? 回答1: Take a look at the io library, which by default has standard-input as the default input file: http://www.lua.org/pil/21.1.html 回答2: local answer repeat io.write("continue with this operation (y/n)? ") io.flush() answer=io.read() until answer=="y" or answer=="n" 回答3: I've worked with code like this. I will type this in a