void tpassword_box::handle_key_delete(SDLMod /*modifier*/, bool& handled) { pre_function(); // Copy & paste from ttext_::handle_key_delete() DBG_GUI_E << LOG_SCOPE_HEADER << '\n'; handled = true; if(get_selection_length() != 0) { delete_selection(); } else if (get_selection_start() < get_text_length(text())) { delete_char(false); } post_function(); }
st TextInput::event_for_keyboard(WL::KeyBoardEvent* e) { if(e->get_type() == WL::KeyBoardEvent::Char && e->get_char() == 8) { self->has_change = TRUE; if(self->filter) return self->filter(this, e, self->extra); return FALSE; } if(get_text_length() >= self->max_len) return TRUE; self->has_change = TRUE; if(self->filter) return self->filter(this, e, self->extra); return FALSE; }
void tpassword_box::post_function() { // See above size_t selection_start = get_selection_start(); size_t selection_length = get_selection_length(); // Get the input back and make ttext_box forget it real_value_ = get_value(); ttext_box::set_value(std::string(get_text_length(real_value_), '*')); // See above set_selection_start(selection_start); set_selection_length(selection_length); // Why do the selection functions not update // the canvas? update_canvas(); set_dirty(true); }
void tpassword_box::set_value(const std::string& text) { ttext_box::set_value(text); real_value_ = get_value(); ttext_box::set_value(std::string(get_text_length(real_value_), '*')); }