Skip to content
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

Blue border around uneditable textbox #656

Open
ErrorFlynn opened this issue Apr 20, 2022 · 3 comments
Open

Blue border around uneditable textbox #656

ErrorFlynn opened this issue Apr 20, 2022 · 3 comments

Comments

@ErrorFlynn
Copy link
Contributor

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.

@ashbob999
Copy link

This blue border is displayed when the textbox gets focused, either by hovering or clicking. The border is added in two different places.

  • The first is in nana::detail::edge_nimbus_renderer in drawer.cpp, which adds a 2px blue border around the 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.

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.

@ErrorFlynn
Copy link
Contributor Author

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.

@ashbob999
Copy link

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants