Open ErrorFlynn opened 2 years ago
This blue border is displayed when the textbox gets focused, either by hovering or clicking. The border is added in two different places.
nana::detail::edge_nimbus_renderer
in drawer.cpp, which adds a 2px blue border around the textbox.nana::element::border_depressed
in element.cpp which replaces the textbox border with a blue border when the textbox is focused by clicking on it.The first option is easy to fix, you just need to call the function below when you set editable to false.
api::effects_edge_nimbus(textbox, effects::edge_nimbus::none);
If you wanted to restore the original behaviour you would need to call the above function twice with different parameters (when editable is set back to true).
api::effects_edge_nimbus(textbox, effects::edge_nimbus::active);
api::effects_edge_nimbus(textbox, effects::edge_nimbus::over);
As for the second border there is currently no way to remove it. But most the code is already in place.
Because text_editor
has a customized_renderers
variable (see here), which could be used to customise the border drawing.
But the variable is not accessible externally, and there would also need to be a way to get the text_editor
object for the specified textbox.
The second is from nana::element::border_depressed in element.cpp which replaces the textbox border with a blue border when the textbox is focused by clicking on it.
That's the one I was talking about, thanks for the info. Not sure what could be done about it, but now at least I know what's happening.
I have created a pull request for this (#659). Which add a new function textbox::enable_border_focused
.
When it gets merged you will be able to do something like this:
form fm;
textbox tb{ fm };
// disable the hovering focus border
api::effects_edge_nimbus(tb, effects::edge_nimbus::none);
// disable the clicked focus border
tb.enable_border_focused(false);
// do stuff here........
// enable the hovering focus border
api::effects_edge_nimbus(textbox, effects::edge_nimbus::active);
api::effects_edge_nimbus(textbox, effects::edge_nimbus::over);
// enable the clicked focus border
tb.enable_border_focused(true);
I'm not sure what the blue border is supposed to indicate, but it probably shouldn't be displayed when the textbox is uneditable. Currently it happens when the user clicks on an uneditable textbox (and maybe it's also correlated with the text changing, I don't know). I've looked at the code to see why it happens, but haven't been able to find anything.