Hi, I''d like to ask if it is possible to control the length of the text displayed in FXText via the FXDataTarget object? I tried something like that but it did not work: require "rubygems" require "fox16" include Fox class MyProject < FXMainWindow def initialize (app, title) super(app,title, :opts=>DECOR_ALL^(DECOR_SHRINKABLE| DECOR_STRETCHABLE|DECOR_RESIZE)| LAYOUT_EXPLICIT,:width=>400,:height=>300) @target=FXDataTarget.new("jkjkjk") do |cmd| cmd.connect(SEL_CHANGED) do |sender, sel, data| if data.length>10 FXApp.instance.beep sender.value=data[0..9] end end end @text=FXText.new (self,:x=>2, :y=>2,:width=>216, :height=>60,:target => @target, :selector => FXDataTarget::ID_VALUE,:opts=>LAYOUT_EXPLICIT) end def create super show(PLACEMENT_SCREEN) end end app = FXApp.new MyProject.new(app, "test") app.create app.run thanks Krzys
On Dec 29, 2008, at 6:34 PM, kwicher wrote:> I''d like to ask if it is possible to control the length of the text > displayed in FXText via the FXDataTarget object? > I tried something like that but it did not work:<snip> If I understand your question correctly, the answer is no. The FXDataTarget only sends a SEL_CHANGED message in response to receiving SEL_CHANGED from some other object. So in your example, the block that checks the data length will only get triggered if someone tries to edit the text in the FXText window. Now, the block won''t get exercised if you change the FXDataTarget''s value directly. But if your goal is to limit the length of the text, you can presumably (?) just do that check whenever you change the value of the data target in the first place. Hope this helps. Please follow up if I''ve misunderstood the question. -- Lyle