-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More Form Enhancements #138
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -48,6 +48,12 @@ added event callback | |||||
*/ | ||||||
|
||||||
//constants | ||||||
enum clipboard_flags | ||||||
{ | ||||||
clipboard_flag_copy = 1 << 0, | ||||||
clipboard_flag_cut = 1 << 1, | ||||||
clipboard_flag_paste = 1 << 2 | ||||||
} | ||||||
enum control_types { | ||||||
ct_button = 0, | ||||||
ct_input, | ||||||
|
@@ -270,6 +276,8 @@ class audio_form { | |||||
c_form[control_counter].caption = caption.replace("&", "", true); | ||||||
c_form[control_counter].visible = true; | ||||||
c_form[control_counter].enabled = true; | ||||||
c_form[control_counter].enable_delete = true; | ||||||
set_clipboard_flags(control_counter, true, true, true); | ||||||
c_form[control_counter].speech_output = speech_output; | ||||||
if ((maximum_length > 0) && (default_text.length() > maximum_length)) { | ||||||
default_text = default_text.substr(0, maximum_length); | ||||||
|
@@ -1146,6 +1154,40 @@ class audio_form { | |||||
c_form[control_index].visible = visible; | ||||||
return true; | ||||||
} | ||||||
bool set_enable_delete(int control_index, bool enabled) { | ||||||
form_error = 0; | ||||||
if (!active) { | ||||||
form_error = form_error_no_window; | ||||||
return false; | ||||||
} | ||||||
if ((control_index < 0) || (control_index > c_form.length() - 1)) { | ||||||
form_error = form_error_invalid_control; | ||||||
return false; | ||||||
} | ||||||
if (!c_form[control_index].active) { | ||||||
form_error = form_error_invalid_control; | ||||||
return false; | ||||||
} | ||||||
c_form[control_index].enable_delete = enabled; | ||||||
return true; | ||||||
} | ||||||
bool set_delete_disabled_message(int control_index, string message) { | ||||||
form_error = 0; | ||||||
if (!active) { | ||||||
form_error = form_error_no_window; | ||||||
return false; | ||||||
} | ||||||
if ((control_index < 0) || (control_index > c_form.length() - 1)) { | ||||||
form_error = form_error_invalid_control; | ||||||
return false; | ||||||
} | ||||||
if (!c_form[control_index].active) { | ||||||
form_error = form_error_invalid_control; | ||||||
return false; | ||||||
} | ||||||
c_form[control_index].delete_disabled_message = message; | ||||||
return true; | ||||||
} | ||||||
bool set_enable_go_to_index(int control_index, bool enabled) { | ||||||
form_error = 0; | ||||||
if (!active) { | ||||||
|
@@ -1928,6 +1970,27 @@ class audio_form { | |||||
} | ||||||
return true; | ||||||
} | ||||||
bool set_input_read_only(int control_index, bool read_only) { | ||||||
form_error = 0; | ||||||
if (!active) { | ||||||
form_error = form_error_no_window; | ||||||
return false; | ||||||
} | ||||||
if ((control_index < 0) || (control_index > c_form.length() - 1)) { | ||||||
form_error = form_error_invalid_index; | ||||||
return false; | ||||||
} | ||||||
if (c_form[control_index].type != ct_input) { | ||||||
form_error = form_error_invalid_control; | ||||||
return false; | ||||||
} | ||||||
if (!c_form[control_index].active) { | ||||||
form_error = form_error_invalid_control; | ||||||
return false; | ||||||
} | ||||||
c_form[control_index].read_only = read_only; | ||||||
return true; | ||||||
} | ||||||
bool set_slider(int control_index, double value, double min = -1, double max = -1) { | ||||||
form_error = 0; | ||||||
if (!active) { | ||||||
|
@@ -2123,6 +2186,23 @@ class audio_form { | |||||
c_form[control_index].echo_flag = keyboard_echo; | ||||||
return true; | ||||||
} | ||||||
bool set_clipboard_flags(int control_index, bool copy, bool cut, bool paste) { | ||||||
form_error = 0; | ||||||
if (!active) { | ||||||
form_error = form_error_no_window; | ||||||
return false; | ||||||
} | ||||||
if ((control_index < 0) || (control_index > c_form.length() - 1)) { | ||||||
form_error = form_error_invalid_index; | ||||||
return false; | ||||||
} | ||||||
if (!c_form[control_index].active) { | ||||||
form_error = form_error_invalid_control; | ||||||
return false; | ||||||
} | ||||||
c_form[control_index].clipboard_flags = ((copy ? clipboard_flag_copy : 0) | (cut ? clipboard_flag_cut : 0) | (paste ? clipboard_flag_paste : 0)); | ||||||
return true; | ||||||
} | ||||||
bool set_keyboard_echo(int control_index, int keyboard_echo) { | ||||||
form_error = 0; | ||||||
if (!active) { | ||||||
|
@@ -2512,14 +2592,18 @@ class control { | |||||
string[] disallowed_chars; | ||||||
bool use_only_disallowed_chars; | ||||||
string char_disallowed_description; | ||||||
bool enable_delete; | ||||||
string delete_disabled_message; | ||||||
bool enable_go_to_index; //This is mostly used on go to index field where it prevents the key from pressing again. | ||||||
bool enable_search; | ||||||
uint8 clipboard_flags; | ||||||
control() { | ||||||
progress_time.restart(); | ||||||
progress_time.pause(); | ||||||
multinav_timer.restart(); | ||||||
multinav_timer.pause(); | ||||||
caption = ""; | ||||||
custom_type = ""; | ||||||
text = ""; | ||||||
password_mask = ""; | ||||||
type = -1; | ||||||
|
@@ -2657,19 +2741,27 @@ class control { | |||||
else | ||||||
add(char); | ||||||
} | ||||||
if (((key_down(KEY_LCTRL)) || (key_down(KEY_RCTRL))) && (key_repeating(KEY_X)) && password_mask == "") | ||||||
if ((clipboard_flags & clipboard_flag_cut > 0) && (keyboard_modifiers & KEYMOD_CTRL > 0) && (key_repeating(KEY_X)) && password_mask == "") | ||||||
cut_highlighted(); | ||||||
if (((key_down(KEY_LCTRL)) || (key_down(KEY_RCTRL))) && (key_repeating(KEY_V)) || key_pressed(KEY_PASTE)) | ||||||
if ((clipboard_flags & clipboard_flag_paste > 0) && (keyboard_modifiers & KEYMOD_CTRL > 0) && (key_repeating(KEY_V)) || key_pressed(KEY_PASTE)) | ||||||
paste_text(); | ||||||
if (key_repeating(KEY_BACK)) { | ||||||
if ((key_down(KEY_LCTRL) || key_down(KEY_RCTRL)) && (sel_start < 0 || sel_end < 0 || sel_start > sel_end)) { | ||||||
if (!enable_delete) { | ||||||
speak(delete_disabled_message); | ||||||
return; | ||||||
} | ||||||
if ((keyboard_modifiers & KEYMOD_CTRL > 0) && (sel_start < 0 || sel_end < 0 || sel_start > sel_end)) { | ||||||
delete_word_left(); | ||||||
return; | ||||||
} | ||||||
delete_highlighted(); | ||||||
} | ||||||
if (key_repeating(KEY_DELETE)) { | ||||||
if ((key_down(KEY_LCTRL) || key_down(KEY_RCTRL)) && (sel_start < 0 || sel_end < 0 || sel_start > sel_end)) { | ||||||
if (!enable_delete) { | ||||||
speak(delete_disabled_message); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return; | ||||||
} | ||||||
if ((keyboard_modifiers & KEYMOD_CTRL > 0) && (sel_start < 0 || sel_end < 0 || sel_start > sel_end)) { | ||||||
delete_word_right(); | ||||||
return; | ||||||
} | ||||||
|
@@ -2680,7 +2772,7 @@ class control { | |||||
} | ||||||
if (((key_down(KEY_LCTRL)) || (key_down(KEY_RCTRL))) && key_up(KEY_LSHIFT) && key_up(KEY_RSHIFT) && (key_repeating(KEY_A))) | ||||||
highlight_all(); | ||||||
if (((key_down(KEY_LCTRL)) || (key_down(KEY_RCTRL))) && (key_repeating(KEY_C)) && (password_mask == "")) | ||||||
if ((clipboard_flags & clipboard_flag_copy > 0) && (keyboard_modifiers & KEYMOD_CTRL > 0) && (key_repeating(KEY_C)) && (password_mask == "")) | ||||||
copy_highlighted(); | ||||||
if (key_repeating(KEY_LEFT)) { | ||||||
if ((key_down(KEY_LCTRL)) || (key_down(KEY_RCTRL))) { | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.