Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Commit

Permalink
add set_hint_text and configure_button
Browse files Browse the repository at this point in the history
  • Loading branch information
FenrirWolf committed Apr 29, 2018
1 parent c490600 commit 4f77677
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion ctru-rs/src/applets/swkbd.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::mem;
use std::str;

use libctru::{self, SwkbdState, swkbdInit, swkbdSetFeatures, swkbdInputText};
use libctru::{self, SwkbdState, swkbdInit, swkbdSetFeatures, swkbdSetHintText, swkbdInputText,
swkbdSetButton};

use libc;

Expand Down Expand Up @@ -155,6 +156,26 @@ impl Swkbd {
self.state.max_digits = digits;
}

/// Sets the hint text for this software keyboard (that is, the help text that is displayed
/// when the textbox is empty)
pub fn set_hint_text(&mut self, text: &str) {
unsafe {
swkbdSetHintText(self.state.as_mut(), text.as_ptr());
}
}

/// Configures the look and behavior of a button for this keyboard.
///
/// `button` is the `Button` to be configured
/// `text` configures the display text for the button
/// `submit` configures whether pressing the button will accept the keyboard's input or
/// discard it.
pub fn configure_button(&mut self, button: Button, text: &str, submit: bool) {
unsafe {
swkbdSetButton(self.state.as_mut(), button as u32, text.as_ptr(), submit);
}
}

/// Configures the maximum number of UTF-16 code units that can be entered into the software
/// keyboard. By default the limit is 0xFDE8 code units.
///
Expand Down

0 comments on commit 4f77677

Please sign in to comment.