From 264553dc283c0b3833a1f24de8d38951acd5c273 Mon Sep 17 00:00:00 2001 From: phil294 Date: Sat, 23 Mar 2024 00:16:38 +0100 Subject: [PATCH] Fix control get text, e.g. in win matching criteria control argument was broken since last gi-repo update, not in previous release fixes #74 --- src/run/display/at-spi.cr | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/run/display/at-spi.cr b/src/run/display/at-spi.cr index 2b6e738..9840b5e 100644 --- a/src/run/display/at-spi.cr +++ b/src/run/display/at-spi.cr @@ -305,8 +305,14 @@ module Run parent.select_child(child_i) if parent end def get_text(accessible) - text = accessible.text_iface.text(0, -1).gsub('', "").strip() - text = accessible.name.gsub('', "").strip() if text.empty? + # the null pointer check is missing so this needs some improved handling. TODO: probably should be fixed in atspi shard instead? + _txt_iface = LibAtspi.atspi_accessible_get_text(accessible.to_unsafe) + if ! _txt_iface.null? + text = ::Atspi::AbstractText.new(_txt_iface, GICrystal::Transfer::Full).text(0, -1).gsub('', "").strip() + end + if text.nil? || text.empty? + text = accessible.name.gsub('', "").strip() + end text.empty? ? nil : text end def set_text(accessible, text)