示教器内置键盘使用说明 
内置键盘类型 
- 标准键盘
void registerStandardKeyboard(
        QWidget *wd, std::function<std::string(void)> init_cb = nullptr,
        const std::shared_ptr<InputValidator> &validator = nullptr,
        std::function<void(std::string)> result_cb = nullptr);- string 类型键盘
void registerStringKeyboard(
        QWidget *wd, std::function<std::string(void)> init_cb = nullptr,
        const std::shared_ptr<InputValidator> &validator = nullptr,
        std::function<void(std::string)> result_cb = nullptr);- 表达式键盘
void registerExpressionKeyboard(
        QWidget *wd, std::function<ExpressionPtr(void)> init_cb = nullptr,
        std::function<void(ExpressionPtr result_value)> result_cb = nullptr);- 密码键盘
void registerPasswordKeyboard(
        QWidget *wd, std::function<std::string(void)> init_cb = nullptr,
        const std::shared_ptr<InputValidator> &validator = nullptr,
        std::function<void(std::string)> result_cb = nullptr);- 输入ip地址专用键盘
void registerIPAddressKeyboard(
        QWidget *wd, std::function<std::string(void)> init_cb = nullptr,
        std::function<void(std::string)> result_cb = nullptr);- 浮点数字键盘
void registerDoubleKeyboard(
        QWidget *wd, std::function<std::string(void)> init_cb = nullptr,
        const std::shared_ptr<InputValidator> &validator = nullptr,
        std::function<void(std::string)> result_cb = nullptr);- 正浮点数字键盘
void registerPositiveDoubleKeyboard(
        QWidget *wd, std::function<std::string(void)> init_cb = nullptr,
        const std::shared_ptr<InputValidator> &validator = nullptr,
        std::function<void(std::string)> result_cb = nullptr);- 整数键盘
void registerIntegerKeyboard(
        QWidget *wd, std::function<std::string(void)> init_cb = nullptr,
        const std::shared_ptr<InputValidator> &validator = nullptr,
        std::function<void(std::string)> result_cb = nullptr);- 正整数键盘
void registerPositiveIntegerKeyboard(
        QWidget *wd, std::function<std::string(void)> init_cb = nullptr,
        const std::shared_ptr<InputValidator> &validator = nullptr,
        std::function<void(std::string)> result_cb = nullptr);- 代码编辑键盘
void registerCodeEditerKeyboard(
        QWidget *wd, std::function<std::string(void)> init_cb = nullptr,
        const std::shared_ptr<InputValidator> &validator = nullptr,
        std::function<void(std::string)> result_cb = nullptr);- 数字键盘
void registerNumberKeyboard(
        QWidget *wd, std::function<std::string(void)> init_cb = nullptr,
        const std::shared_ptr<InputValidator> &validator = nullptr,
        std::function<void(std::string)> result_cb = nullptr);插件调用内置键盘 
插件的安装节点、程序节点若需要调用 ARCS 软件内置的键盘,需调用节点的 view 类,view 类提供了 ViewApiProviderPtr view_api_{ nullptr }; 接口,使用不同类型键盘的函数时需要注意参数类型,具体的参数类型请在代码中转至定义进行查看。
接口位置 
程序节点和安装节点中可调用键盘的接口位置,在程序和安装节点 view 类中如下图所示。

接口调用 
- 在安装节点或程序节点中 - contribution类头文件中声明键盘管理类指针变量:- std::shared_ptr<arcs::aubo_scope::KeyboardManager> keyboard_manager_;
- 在程序节点或者安装节点的 - contribution类- buildUi函数中为需要获取- KeyboardManager接口:- keyboard_manager_ = view_api_->getUserInterfaceApi()->getUserInteraction()->getKeyboardManager();
- 调用接口中的注册键盘函数: - keyboard_manager_->registerDoubleKeyboard( ui->le_test, [=]() -> std::string { return ui->le_test->text().toStdString(); }, std::make_shared<DoubleRangeValidator>([=]() -> std::pair<double, double> { return { -100.0, 100.0 }; }), [=](const std::string &text) { ui->le_test->setText(text.c_str()); });
- 查看效果。  
常见问题 
常见问题 1:弹窗中无法正常使用键盘 
问题描述: 弹窗中的输入框无法正常使用键盘,点两下键盘就会消失。
问题原因: QDialog::exec(); 的阻塞运行方式抢占键盘的焦点事件,需使用 QDialog::open(); 配合 QEventLoop::exec() 实现。
解决方案: 重写 CustomInputDialog::exec 方法。
原代码:
CustomInputDialog dialog(s1, s2);
if(dialog.exec() == QDialog::Accepted){
    ....
}
重写 CustomInputDialog::exec 方法为:
int CustomInputDialog::exec() {
    QEventLoop loop;
    connect(this, &QDialog::finished, this, [&]{
        loop.exit();
    });
    open(); ///< exec 会抢占键盘焦点,改用 open.
    loop.exec(QEventLoop::DialogExec);
    return result();
}










