mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
C++: Use concepts for the invokables
This commit is contained in:
parent
a3ec320bfb
commit
63cc68ea0c
4 changed files with 35 additions and 22 deletions
|
@ -670,8 +670,11 @@ public:
|
|||
///
|
||||
/// Note: Since the ComponentInstance holds the handler, the handler itself should not
|
||||
/// capture a strong reference to the instance.
|
||||
template<typename F>
|
||||
bool set_callback(std::string_view name, F callback) const
|
||||
// clang-format off
|
||||
template<std::invocable<std::span<const Value>> F>
|
||||
requires(std::is_convertible_v<std::invoke_result_t<F, std::span<const Value>>, Value>)
|
||||
auto set_callback(std::string_view name, F callback) const -> bool
|
||||
// clang-format on
|
||||
{
|
||||
using cbindgen_private::ValueOpaque;
|
||||
auto actual_cb = [](void *data, cbindgen_private::Slice<ValueOpaque> arg,
|
||||
|
@ -741,7 +744,7 @@ public:
|
|||
///
|
||||
/// **Note:** Only globals that are exported or re-exported from the main .slint file will
|
||||
/// be accessible
|
||||
template<typename F>
|
||||
template<std::invocable<std::span<const Value>> F>
|
||||
bool set_global_callback(std::string_view global, std::string_view name, F callback) const
|
||||
{
|
||||
using cbindgen_private::ValueOpaque;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue