public:
ClearCommand(const ::aurum::ReqClear* request, ::aurum::RspClear* response);
- ;
::grpc::Status execute() override;
+
+protected:
+ bool hasHintText(UiObject *obj);
};
#endif
\ No newline at end of file
#include "ClearCommand.h"
#include <UiObject.h>
#include <loguru.hpp>
-
#include <string>
ClearCommand::ClearCommand(const ::aurum::ReqClear* request,
{
}
+bool ClearCommand::hasHintText(UiObject *obj)
+{
+ if (!obj) return false;
+
+ auto old_text = obj->getText();
+ obj->setText("");
+ if (!old_text.compare(obj->getText())) {
+ return true;
+ } else {
+ obj->setText(old_text);
+ return false;
+ }
+}
+
::grpc::Status ClearCommand::execute()
{
LOG_SCOPE_F(INFO, "Clear --------------- ");
UiObject* obj = mObjMap->getElement(mRequest->elementid());
if (obj) {
- std::string empty{};
- obj->setText(empty);
- mResponse->set_status(::aurum::RspStatus::OK);
+ obj->setText("");
+ obj->refresh();
+ auto text = obj->getText();
+ if (text.length() != 0) {
+ if (hasHintText(obj)) {
+ mResponse->set_status(::aurum::RspStatus::OK);
+ } else {
+ mResponse->set_status(::aurum::RspStatus::ERROR);
+ }
+ } else {
+ mResponse->set_status(::aurum::RspStatus::OK);
+ }
}
return grpc::Status::OK;
::grpc::Status SetValueCommand::execute()
{
- LOG_SCOPE_F(INFO, "SetValue --------------- ");
+ LOG_SCOPE_F(INFO, "SetValue (text:%s) --------------- ", mRequest->stringvalue().c_str());
ObjectMapper* mObjMap = ObjectMapper::getInstance();
UiObject* obj = mObjMap->getElement(mRequest->elementid());
if (obj) obj->setText(const_cast<std::string&>(mRequest->stringvalue()));
- LOG_F(INFO, "%p %s", obj, mRequest->stringvalue().c_str());
return grpc::Status::OK;
}
\ No newline at end of file
void print(int, int) const;
void refresh() const;
- void setValue(std::string &text) const;
+ void setValue(std::string text) const;
private:
bool isSupporting(AccessibleNodeInterface thisIface) const;
std::string getResourceName() const;
std::string getText() const;
- void setText(std::string &text);
+ void setText(std::string text);
const Rect<int> getBoundingBox() const;
return mNode.get();
}
-void AccessibleNode::setValue(std::string &text) const
+void AccessibleNode::setValue(std::string text) const
{
AtspiEditableText *iface = atspi_accessible_get_editable_text(mNode.get());
+ LOG_F(INFO,"set Value iface:%p obj:%p text:%s", iface, mNode.get(), text.c_str() );
if (iface) {
+ int len = getText().length();
+ atspi_editable_text_delete_text(iface, 0, len, NULL);
atspi_editable_text_insert_text(iface, 0, text.c_str(), text.length(),
NULL);
}
return getAccessibleNode()->getText();
}
-void UiObject::setText(std::string &text)
+void UiObject::setText(std::string text)
{
getAccessibleNode()->setValue(text);
}