-
Notifications
You must be signed in to change notification settings - Fork 5
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
Dealing with type conversion errors on accept #16
Comments
|
The "accept" callbackWith in the window.add_action_callback('accept') { |action_context, values|
if $VERBOSE || Sketchup.debug_mode?
puts "HtmlUI::InputBox - callback 'accept':\n "<<values.inspect
end
begin
results = type_convert(@options, values)
rescue ValueConversionError => err
indices = err.message # array of indices in JSON string
window.execute_script(%[app.markProblemInputs('#{indices}');])
UI.beep
else
window.close
end
}
So if the user flubs a A new CSS rule to mark problem inputsI have added a new CSS class rule to .bad-value, .bad-value:focus {
background-color: #ffdcdc;
} This is light pastel pink color. Adding an ID to the
|
Dealing with type conversion errors on accept.
When the user presses ENTER or clicks the "Accept" button, the
app
's "accept" function fires and passes the input values to the Ruby "accept" callback. The Ruby callback proc then passes thisvalues
array to thetype_convert()
method for conversion (from JS strings) back into the correctly typed Ruby objects.But handling of incorrectly entered values by the user is needed.
Future JS side validation
NOTE: Down the road another "subproject" is to implement validation within the Vue JS form, so we need not go back and forth to Ruby - back to JS - repeat, ... etc.
String
No problems with string values. They remain as strings on both sides (Ruby and JS.)
Float
andInteger
Currently if the user incorrectly enters values for
Float
orInteger
, Ruby's conversion methods just default to0.0
and0
respectively. I will be looking at testing the values using regular expressions for these 2 situations. Something like:In testing, I also think it might be best to run the integer values though a float ... ie ...
... see next post regarding
Length
value conversion ...The text was updated successfully, but these errors were encountered: