Skip to content

Commit

Permalink
Add TextInput#message for mobile text inputs (#155)
Browse files Browse the repository at this point in the history
* feat: Add TextInput#message for mobile text inputs

* chore: Add isEmpty checks
  • Loading branch information
phinner authored Sep 15, 2023
1 parent 867271d commit 70f345c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions arc-core/src/arc/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ public static class TextInput{
public boolean allowEmpty = true;
public String title = "";
public String text = "";
public String message = "";
public boolean numeric;
public Cons<String> accepted = s -> { };
public Runnable canceled = () -> { };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public Vec3 getOrientation(){
public void getTextInput(TextInput info){
handle.post(() -> {
AlertDialog.Builder alert = new AlertDialog.Builder(context);
if(!info.message.isEmpty()) alert.setMessage(info.message);
//alert.setTitle(info.title);
final EditText input = new EditText(context);
input.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN);
Expand Down
2 changes: 2 additions & 0 deletions backends/backend-robovm/src/arc/backend/robovm/IOSInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public void getTextInput(TextInput input){
}

UIAlertController alert = new UIAlertController(input.title, null);
if(!input.message.isEmpty()) alert.setMessage(input.message);
alert.getKeyValueCoder().setValue("contentViewController", controller);
alert.addAction(new UIAlertAction("Ok", UIAlertActionStyle.Default, action -> Core.app.post(() -> input.accepted.get(text.getText()))));
alert.addAction(new UIAlertAction("Cancel", UIAlertActionStyle.Destructive, action -> Core.app.post(input.canceled)));
Expand Down Expand Up @@ -259,6 +260,7 @@ public void cancel(UIAlertView view){
// build the view
UIAlertView uiAlertView = new UIAlertView();
uiAlertView.setTitle(input.title);
if(!input.message.isEmpty()) uiAlertView.setMessage(input.message);
uiAlertView.addButton("Cancel");
uiAlertView.addButton("Ok");
uiAlertView.setAlertViewStyle(UIAlertViewStyle.PlainTextInput);
Expand Down

0 comments on commit 70f345c

Please sign in to comment.