mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-14 06:58:35 +00:00
working on some tests. this commit is broken
This commit is contained in:
parent
71a0f73034
commit
9b27edf440
@ -76,11 +76,23 @@ fn main() {
|
||||
ctrl_a_counter
|
||||
));
|
||||
|
||||
struct Cback;
|
||||
impl TextCallbackHandler for Cback {
|
||||
fn char_filter(&mut self, c: char, txt: &TextInformation<'_>) -> Option<char> {
|
||||
if c == 'a' {
|
||||
None
|
||||
} else {
|
||||
Some(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Note that `is_key_released` gives the state of the
|
||||
// key regardless of what widget has focus, for
|
||||
// example, if you try to type into this input, the
|
||||
// above interaction still counts the key presses.
|
||||
ui.input_text(im_str!("##Dummy text input widget"), &mut text_buffer)
|
||||
.callback(InputTextCallback::CHAR_FILTER, &mut Cback)
|
||||
.hint(im_str!("Example text input"))
|
||||
.build();
|
||||
|
||||
|
||||
@ -116,14 +116,14 @@ struct CallbackData<'a> {
|
||||
user_data: &'a mut UserData<'a>,
|
||||
}
|
||||
|
||||
pub struct TextCallbackData<'a> {
|
||||
pub event_flag: InputTextFlags,
|
||||
pub flags: InputTextFlags,
|
||||
pub user_data: UserData<'a>,
|
||||
pub event_char: char,
|
||||
pub event_key: EventDirection,
|
||||
pub buf: TextCallbackBuffer<'a>,
|
||||
}
|
||||
// pub struct TextCallbackData<'a> {
|
||||
// pub event_flag: InputTextFlags,
|
||||
// pub flags: InputTextFlags,
|
||||
// pub user_data: UserData<'a>,
|
||||
// pub event_char: char,
|
||||
// pub event_key: EventDirection,
|
||||
// pub buf: TextCallbackBuffer<'a>,
|
||||
// }
|
||||
|
||||
pub struct TextCallbackBuffer<'a> {
|
||||
buf: &'a mut str,
|
||||
@ -295,10 +295,10 @@ extern "C" fn callback(data: *mut sys::ImGuiInputTextCallbackData) -> c_int {
|
||||
let text_info = TextInformation {
|
||||
flags: InputTextFlags::from_bits((*data).Flags as u32).unwrap(),
|
||||
buf: TextCallbackBuffer {
|
||||
buf: std::str::from_utf8_mut(std::slice::from_raw_parts_mut(
|
||||
buf: std::str::from_utf8_mut(dbg!(std::slice::from_raw_parts_mut(
|
||||
(*data).Buf as *mut u8,
|
||||
(*data).BufSize as usize - 1,
|
||||
))
|
||||
(*data).BufSize as usize,
|
||||
)))
|
||||
.expect("internal imgui error -- it boofed a utf8"),
|
||||
dirty: &mut (*data).BufDirty,
|
||||
cursor_pos: &mut (*data).CursorPos,
|
||||
|
||||
@ -20,8 +20,9 @@ pub use self::fonts::glyph_ranges::*;
|
||||
pub use self::input::keyboard::*;
|
||||
pub use self::input::mouse::*;
|
||||
pub use self::input_widget::{
|
||||
InputFloat, InputFloat2, InputFloat3, InputFloat4, InputInt, InputInt2, InputInt3, InputInt4,
|
||||
InputText, InputTextFlags, InputTextMultiline,
|
||||
EventDirection, InputFloat, InputFloat2, InputFloat3, InputFloat4, InputInt, InputInt2,
|
||||
InputInt3, InputInt4, InputText, InputTextCallback, InputTextMultiline, TextCallbackBuffer,
|
||||
TextCallbackHandler, TextInformation, InputTextFlags
|
||||
};
|
||||
pub use self::io::*;
|
||||
pub use self::layout::*;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user