mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-06-28 19:11:13 +08:00
Added a decorator to prevent selectability
This commit is contained in:
parent
307d8b51bf
commit
d62dc6e305
@ -47,7 +47,7 @@ int main() {
|
|||||||
window(text("Vertical split"), vbox({
|
window(text("Vertical split"), vbox({
|
||||||
LoremIpsum(),
|
LoremIpsum(),
|
||||||
separator(),
|
separator(),
|
||||||
LoremIpsum(),
|
LoremIpsum() | unselectable,
|
||||||
separator(),
|
separator(),
|
||||||
LoremIpsum(),
|
LoremIpsum(),
|
||||||
})),
|
})),
|
||||||
|
@ -113,6 +113,7 @@ Decorator focusPositionRelative(float x, float y);
|
|||||||
Element automerge(Element child);
|
Element automerge(Element child);
|
||||||
Decorator hyperlink(std::string link);
|
Decorator hyperlink(std::string link);
|
||||||
Element hyperlink(std::string link, Element child);
|
Element hyperlink(std::string link, Element child);
|
||||||
|
Element unselectable(Element child);
|
||||||
|
|
||||||
// --- Layout is
|
// --- Layout is
|
||||||
// Horizontal, Vertical or stacked set of elements.
|
// Horizontal, Vertical or stacked set of elements.
|
||||||
|
@ -5,8 +5,22 @@
|
|||||||
#include "ftxui/dom/selection.hpp" // for Selection
|
#include "ftxui/dom/selection.hpp" // for Selection
|
||||||
#include <algorithm> // for max, min
|
#include <algorithm> // for max, min
|
||||||
|
|
||||||
|
#include "ftxui/dom/elements.hpp" // for Element, inverted
|
||||||
|
#include "ftxui/dom/node_decorator.hpp" // for NodeDecorator
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class Unselectable : public NodeDecorator {
|
||||||
|
public:
|
||||||
|
using NodeDecorator::NodeDecorator;
|
||||||
|
|
||||||
|
void Select(Selection& selection) override {
|
||||||
|
// Overwrite the select method to do nothing.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
/// @brief Create a selection.
|
/// @brief Create a selection.
|
||||||
/// @param start_x The x coordinate of the start of the selection.
|
/// @param start_x The x coordinate of the start of the selection.
|
||||||
/// @param start_y The y coordinate of the start of the selection.
|
/// @param start_y The y coordinate of the start of the selection.
|
||||||
@ -103,4 +117,11 @@ Selection Selection::SaturateVertical(Box box) {
|
|||||||
return Selection(start_x, start_y, end_x, end_y);
|
return Selection(start_x, start_y, end_x, end_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Add a filter that will invert the foreground and the background
|
||||||
|
/// colors.
|
||||||
|
/// @ingroup dom
|
||||||
|
Element unselectable(Element child) {
|
||||||
|
return std::make_shared<Unselectable>(std::move(child));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
|
Loading…
Reference in New Issue
Block a user