Setting Properties of a Gambas GUI Object like: Textarea1.Text=“some text”
already works. This is done by doing live object introspection by the received object name e.g. a Textarea has 106 symbols for properties,methods and events
Received data <–
Textarea1.Text,2020-05-21 11:46:37 +02:00
Key,val: Textarea1.Text 2020-05-21 11:46:37 +02:00
Objname: Textarea1
Prop: Text
(TextArea 0x55e41302e6c8)
TextArea1:
.,H,W,X,Y,Id,Cut,Pos,Tag,Top,_new,Copy,Drag,Drop,Font,Grab,Hide,Left,Line,Move,Name,Next,Redo,Show,Text,Undo,Wrap,:Drag,:Drop,:Menu
,Clear,Lower,Mouse,Paste,Proxy,Raise,ToPos,Width,:Enter,:Leave,Action,Border,Column,Cursor,Delete,Design,Expand,Handle,Height,Ignor
e,Insert,Length,Parent,Resize,Select,ToLine,Window,:Change,:Cursor,_Family,_Parent,Enabled,Hovered,Refresh,ScreenX,ScreenY,Tooltip,
Visible,:MouseUp,_Similar,CursorAt,HasFocus,Previous,ReadOnly,Reparent,Selected,SetFocus,ToColumn,Tracking,Unselect,:DblClick,:Drag
Move,:GotFocus,:KeyPress,Alignment,PopupMenu,ScrollBar,SelectAll,Selection,:DragLeave,:LostFocus,:MouseDown,:MouseDrag,:MouseMove,_
IsControl,Background,Foreground,MoveScaled,NoTabFocus,:KeyRelease,:MouseWheel,_Properties,_DefaultSize,ResizeScaled,_DefaultEvent,E
nsureVisible,
Symbols found: 106
Events for Button pressed are working, I just send “Button nn Clicked” to crystal.
#connect to Gambas GUI via TCP
require "socket"
GUI_SERVER="localhost"
GUI_PORT=9090
class GuiClient
def send (object,value)
client = TCPSocket.new(GUI_SERVER,GUI_PORT)
client << object + "," + value + "\n"
response = client.gets
client.close
puts
end
end
mygui = GuiClient.new
#send key,value pairs for GUI Objects based on GTK or QT
mygui.send "Textarea1.Text","hello-textarea"
sleep 5.seconds
mygui.send "Textarea1.Text","hello-textarea-more-text"
loop do
mygui.send "Textarea1.Text",Time.local.to_s
sleep 2.seconds
end
sleep
Event for Button clicks forwarded like this:
def receive
spawn do #receiving fiber,handle GUI events
loop do
event = @client.not_nil!.gets
case event
when "Button1 clicked"
@sending=false
when "Button2 clicked"
@sending=true
end
end
end
end
end