[yast-commit] r40966 - /branches/tmp/sh/mod-ui/core/libyui/doc/examples/Tree4.ycp
Author: gs Date: Wed Sep 19 13:36:05 2007 New Revision: 40966 URL: http://svn.opensuse.org/viewcvs/yast?rev=40966&view=rev Log: copied from Tree1.ycp - but use string IDs and set option `notify Added: branches/tmp/sh/mod-ui/core/libyui/doc/examples/Tree4.ycp Added: branches/tmp/sh/mod-ui/core/libyui/doc/examples/Tree4.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/doc/examples/Tree4.ycp?rev=40966&view=auto ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/doc/examples/Tree4.ycp (added) +++ branches/tmp/sh/mod-ui/core/libyui/doc/examples/Tree4.ycp Wed Sep 19 13:36:05 2007 @@ -0,0 +1,100 @@ +// Simple tree example +{ + UI::OpenDialog( + `VBox( + `Tree(`id(`dest_dir), `opt(`notify), + "Select destination directory:", + [ + `item(`id("root"), "/" , true, + [ + `item(`id("etc"), "etc", + [ + `item("opt"), + `item("SuSEconfig"), + `item("X11") + ] + ), + `item("usr", false, + [ + "bin", + "lib", + `item("share", + [ + "man", + "info", + "emacs" + ] + ), + `item(`id("usr_local"),"local"), + `item("X11R6", + [ + "bin", + "lib", + "share", + "man", + "etc" + ] + ) + ] + ), + `item(`id("opt"), "opt", true, + [ + "kde", + "netscape", + "Office51" + ] + ), + `item("home"), + "work", + `item(`id(`other), "<other>") + ] + ) + ] ), + `HBox( + `PushButton(`id(`sel_opt), `opt(`hstretch), "/&opt" ), + `PushButton(`id(`sel_usr), `opt(`hstretch), "/&usr" ), + `PushButton(`id(`sel_usr_local), `opt(`hstretch), "/usr/&local" ) + ), + `PushButton(`id(`ok), `opt(`default), "&OK") + ) + ); + + any id = nil; + + repeat + { + id = UI::UserInput(); + + if ( id == `sel_usr) UI::ChangeWidget(`dest_dir, `CurrentItem, "usr" ); + else if ( id == `sel_usr_local) UI::ChangeWidget(`dest_dir, `CurrentItem, "usr_local" ); + else if ( id == `sel_opt) UI::ChangeWidget(`dest_dir, `CurrentItem, "opt" ); + } until ( id == `ok ); + + // Get the input from the tree. + // + // Notice: The return value of UI::UserInput() does NOT return this value! + // Rather, it returns the ID of the widget (normally the PushButton) + // that caused UI::UserInput() to return. + string dest_dir = (string) UI::QueryWidget(`dest_dir, `CurrentItem); + y2milestone( "Selected: %1", dest_dir ); + + + if ( dest_dir == nil ) + dest_dir = ""; + + // Close the dialog. + // Remember to read values from the dialog's widgets BEFORE closing it! + UI::CloseDialog(); + + + // Pop up a new dialog to echo the selection. + UI::OpenDialog( + `VBox( + `Label("Selected destination directory: " + dest_dir), + `PushButton(`opt(`default), "&OK") + ) + ); + UI::UserInput(); + + UI::CloseDialog(); +} -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
gs@svn.opensuse.org