Professional Web Applications Themes

FXRuby: adding child widgets after #run has started - Ruby

Hello all, Is there a way in Fox to add widgets after the widget hierarchy has been built and FXApp#run has started ? Say, I have an empty FXScrollWindow, and I want to add FXMatrix to it with lots of its own children, on some event (button click, etc). So far, I have not found a way to see the widgets I've added. -- Best regards, Yuri Leikind...

  1. #1

    Default FXRuby: adding child widgets after #run has started

    Hello all,

    Is there a way in Fox to add widgets after the widget hierarchy has been built and
    FXApp#run has started ?


    Say, I have an empty FXScrollWindow, and I want to add FXMatrix to it with
    lots of its own children, on some event (button click, etc).

    So far, I have not found a way to see the widgets I've added.


    --
    Best regards,
    Yuri Leikind



    Yuri Guest

  2. #2

    Default Re: FXRuby: adding child widgets after #run has started

    Yuri Leikind wrote:
     

    See this question from the FOX FAQ list:

    http://www.fox-toolkit.org/faq.html#CREATELATER

    If you add widgets after the program's started, you'll need to call
    create() on them after adding them.

    Lyle Guest

  3. #3

    Default Re: FXRuby: adding child widgets after #run has started

    On Sat, 24 Jan 2004 00:29:58 +0900
    Lyle Johnson <sourceforge.net> wrote:
     
    >
    > See this question from the FOX FAQ list:
    >
    > http://www.fox-toolkit.org/faq.html#CREATELATER
    >
    > If you add widgets after the program's started, you'll need to call
    > create() on them after adding them.[/ref]


    Yes, it does work. In some cases. But in other cases it doesn't. Please take a look at the example:


    require "fox"
    class App < Fox::FXApp

    include Fox

    def initialize
    super("app")
    window = FXMainWindow.new(self,"app", nil, nil, 0, 0, 500, 300)
    contents = FXVerticalFrame.new(window, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y)

    grbox1 = FXGroupBox.new(contents, "Options", GROUPBOX_TITLE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
    build(grbox1, false)

    grbox2 = FXGroupBox.new(contents, "Options", GROUPBOX_TITLE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
    #build(grbox2, false)

    FXButton.new(contents, "Click me").connect(SEL_COMMAND) do
    build(grbox2, true)
    end
    create
    window.show
    run
    end

    def build(parent, creat)
    scrollarea = FXScrollWindow.new(parent, VSCROLLER_ALWAYS|LAYOUT_FILL_X|LAYOUT_FILL_Y)

    scrollable = FXMatrix.new(scrollarea, 2, MATRIX_BY_COLUMNS|LAYOUT_FILL_X, DEFAULT_SPACING,
    DEFAULT_SPACING, DEFAULT_SPACING, DEFAULT_SPACING, 30, 30)


    1.upto(10) do
    FXLabel.new(scrollable, "some name", nil, LABEL_NORMAL)
    FXCheckButton.new(scrollable, "yes", nil, 0, CHECKBUTTON_NORMAL|LAYOUT_SIDE_LEFT)
    end
    scrollarea.create if creat
    end
    end
    App.new


    We have 2 FXScrollWindow instances here, one of which is built before run , another - after.
    So that another FXScrollWindow is never seen. I don't see why.

    --
    Best regards,
    Yuri Leikind


    Yuri Guest

  4. #4

    Default Re: FXRuby: adding child widgets after #run has started


    On Jan 23, 2004, at 12:38 PM, Yuri Leikind wrote:
     

    <snip>
     

    The problem is that merely adding an FXScrollWindow to the FXGroupBox
    during that second call to build() doesn't mark the layout of the group
    box as "dirty". That is to say, FOX doesn't assume that adding the
    scroll window changed the size of the parent group box (grbox2), and so
    that widget's layout doesn't get recalculated as a result. In this
    case, you need to explicitly mark the group box layout as dirty by
    calling its recalc() method. Try adding the following line at the end
    of build(), after the call to FXScrollWindow#create:

    scrollarea.recalc

    and see if you get the result you're after.

    Hope this helps,

    Lyle





    Lyle Guest

  5. #5

    Default Re: FXRuby: adding child widgets after #run has started

    On Sat, 24 Jan 2004 13:50:06 +0900
    Lyle Johnson <net> wrote:
     

    Oh yes, it does, thank you again.


    --
    Best regards,
    Yuri Leikind


    Yuri Guest

Similar Threads

  1. adding multiple child records
    By acidrain9 in forum Dreamweaver AppDev
    Replies: 1
    Last Post: February 19th, 08:14 PM
  2. Replies: 31
    Last Post: December 9th, 11:06 PM
  3. Replies: 2
    Last Post: November 1st, 09:58 PM
  4. Help with FXRuby widgets layout
    By Ruby Ruby in forum Ruby
    Replies: 1
    Last Post: September 22nd, 03:52 PM
  5. problems with adding Camera as child to object
    By Bazmati webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 1
    Last Post: August 14th, 05:29 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139