I have created a Love application but the game requires an on screen keyboard that has arrow keys, is it possible to create buttons on screen like a game pad that simulate keyboard input of keys like the arrow keys or letters?
tl;dr: Use a more common touch input pattern like four touch-input quadrants of the screen.
It is possible but you would need to write an app to somehow pass the key-presses along with the android native keyboard which is a completely different question that is the beyond the scope of this answer.
Refer to the Android Input method documentation for help with that if you decide to go that route.
You could use something like:
if love.system.getOS() == "Android" then
doVirtualKeyboadThings()
end
To detect that your game is running on android, Assuming that you want it to be multi-arch and then use something like Thranduil (Gui Libary) to create your own virtual keyboard.
However I can't encourage such a complicated workaround for something
that could be accomplished with love.mouse (which uses touch events on android) and simple buttons or screen sections.
Example Image
Related
In my application, I want to provide the functionality similar to Next, Previous and Done button at the top of keyboard. It is somewhat similar to this
Please let me know how can I achieve this.
I do not want to exactly implement the next,previous and done options. But using this three button click, I want to make three separate web service calls and fetch the results. Like, Active,Inactive and All kind of filters.
The standard Android way would be to provide an input method action with imeOptions. With the standard keyboard this will change the bottom right virtual keyboard button to the specified action. There's little point in trying to mimic iOS input behavior with the buttons above.
Do you want to just put the layout above the keyboard,so as to stop next,previous,etc button when keyboard is displayed.
If so,you can try adding below code inside your activity in android manifest,
android:windowSoftInputMode="adjustResize"
If you are looking for something else,then please show your xml code of the same.
I want to create a custom keyboard which will be available in my application only (It's used jut for a single EditText in one activity), and I was wondering what would be the best way to do so. Here are my specifications for the keyboard:
It should always be displayed in the activity it is used (Regardless whether the EditText is focused or not).
It will have 2 or more keys layouts (Similar to the regular keyboard which has letters layout and a few numbers/symbols layouts).
Some keys may require some special action (Rather than simply adding their android:codes key value to the EditText).
It doesn't offer candidates for completion/correction.
It doesn't offer more than one input type (Like the regular keyboard which has TYPE_CLASS_NUMBER, TYPE_CLASS_DATETIME and so on...).
How should I develop it? Should I create a full input method service for it? Or should I create just a KeyboardView and add it to the activity's layout? (I want to use KeyboardView for the convenience of keys creation and click events handling)
Since it's a one-off thing and not meant as a separate app, You can simply use whatever method is easiest for you (The KeyboardView method).
Try it out and make sure it's responsive and snappy. If it works, then simple and easy method would be my recommendation.
Maybe you could take a look at this. I think the best way is to make a custom layout and inflate it. Theres a tutorial given here too.
I have a custom view for which I want the user to be able to enter characters from an app-defined set of characters. To do this, as I understand it, I need to write an input method service. The user not only needs to install it, but then needs to enable the IME in the Settings > Language & keyboard, and then select the custom IME for use in the view.
This seems really crazy. I want this IME to be used for just one view in one application. I don't want it to be available system-wide or force the user to make global setting changes.
The only alternative I can see is defining my own in-app custom view and simulate an IME (probably a full-screen one) when the view gains focus. Isn't there anything better?
I do not think the IMEs are conceived for that kind of task. Their concept is to allow user input in a standardized way so it can be used across multiple applications from different vendors.
My strategy would be similar to what you are thinking:
prevent the soft keyboard from appearing,
intercept the menu button key press to show your own instead,
add a custom layout (probably a GridView or a TableView inside a RelativeLayout with bottom gravity)
use an OnItemClickListener
send the required KeyEvents to the root View. If the characters are invented, the KeyCodes do not even need to relate to the ASCII character. You just intercept the code and use at will.
Sorry I can't give you an option as you asked, but this alternative does not seem to be much more work than creating a whole new IME.
Edit: upon reading the related question, it makes sense to use android.inputmethodservice.KeyboardView instead of reinventing the wheel with the GridView.
I am creating an Android game. Currently I'm using a "normal" View and draw, the onDraw() and have a Handler to process timed events and such. However Soon (tm) I will convert it to a SurfaceView with a Thread and a constant loop.
Anyway, when the player presses a certain button, I want to have a kind of edit box for the player to enter a value (a price). But I'm kind of lost on how to achieve this. First I thought, ok let's just make an EditText, position it on the screen, and done. But apparently I can't just put an EditText on an X,Y location and remove it afterwards.
I looked at the LunarLander example, which uses a TextView for displaying text. It is already defined in the layout XML and is turned visible and invisible by sending messages between the game thread and the UI thread. This seems awefully complicated and the edit box would exist all the time.
Furthermore I was thinking on making my own "edit box" by simply drawing a box on the screen, enabling the keyboard, and then capturing input from the keyboard. But I wouldn't even know where to begin with "custom" keyboard input (on screen vs physical, how to capture keyboard text input, how to hide the keyboard again when done, etc).
So I was wondering, what's the best way to do this?
Edit: maybe useful to know, but my game is fixed in landscape mode.
How about popping up a dialog box with some fancy graphics with the EditText in it?
If you want to stick to using only the SurfaceView, then you may have to implement your own simple GUI system. I'd look around, maybe there're some GUI libs out there for android games.
I want to develop a replacement keyboard, but I am afraid that Android assumes the general keyboard 'area' will be a single rectangular shape that sits at the bottom of the screen.
What if I want my keyboard to consist of multiple shapes that don't just sit at the bottom of the screen? Am I doomed from the start, or is it possible to do what I want to do?
On a related note, what if I only want my keyboard to appear when the phone is in a certain orientation but when the phone is held at a different orientation, the normal soft keyboard is used? Again, out of luck or possible?
cheers!
The IME is just a window. It is positioned relative to the bottom of the screen, so you can't really control that. But you can draw whatever you want in it, or not for places you want to be transparent. You can control how much applications move up away from your IME with this: http://developer.android.com/reference/android/inputmethodservice/InputMethodService.html#onComputeInsets(android.inputmethodservice.InputMethodService.Insets)
Android doesn't let windows decide one at a time whether events will be handled by them or dispatched to the window behind them; the only control you have to keep events from being consumed by your entire window is the Insets.touchableInsets constants to tell the window manager to allow events outside of the given insets to go through to what is behind it.
Presumably you could create a rectangle where ever you want and make bits of it transparent. Not sure how to pass UI events to the activity below your keyboard though.
Anyway, there's a softkeyboard sample that will probably be Quite Helpful.
As I see it there are two ways you might handle the UI Thing.
- Pass events off to the underlying activity when they "should go through"... As your softkeyboard may have its own process, this could get a bit thorny.
- Make your keyboard up of more than one rectangular region, such that the UI events pass through Naturally. I'm not sure if that's even possible. I'm still fairly new to Android development myself.