9. Migrating from 1.0 to 2.0 #
← License and demo mode · Contents · Migrating from 2.0 to 3.0 →
2.0 brings five components and reshapes the API of the sixteen from 1.0. The reshaping comes down to three rules; nearly every compile error you will see follows from them. This page gives the rules, a before/after, then, component by component, every signature removed or changed. The components absent from the tables — button, messagebox, picture, pdfviewer, progressbar, webbrowser — have lost nothing.
9.1 The three rules #
1. One key, one address. An item's identifier is called as_key — one level, unique under its parent. A nested item is reached through an address as_keys, levels joined by /: "home/clipboard/paste". Events hand that address back in one argument, where 1.0 passed three (as_tab, as_group, as_id). To split it: n_pbt_utils.of_split_path (as_keys, ref as_out[]).
2. Everything is done from the component. A handle (n_pbt_ribbon_group, n_pbt_toolbar_bar, n_pbt_tilesbox_group, n_pbt_listbar_section…) no longer adds anything: additions and removals live on the component, with the parent's address. Getters are named after the level — of_tab, of_group, of_item, of_menu_item on the ribbon, of_panel on the dock and the status bar, of_page on the tab, of_section on the listbar, of_bar on the toolbar, of_tile on the tiles box. A handle is now only for reading and setting properties.
3. An addition returns a code, not a handle. of_add_tab, of_add_group, of_add_bar, of_add_section… return a long: 0 once applied, -5 on a wrong address (parent missing, or of another kind, empty key), -2 when the component is not created. A handle could not say it had refused; a code can. When a property is to be set, the getter gives the handle right after.
9.2 Before / after #
// 1.0
n_pbt_ribbon_tab lnv_tab
n_pbt_ribbon_group lnv_group
lnv_tab = uo_ribbon.of_add_tab("home", "Home")
lnv_group = lnv_tab.of_add_group("clip", "Clipboard")
lnv_group.of_add_button("paste", "Paste", "img/paste.svg")
lnv_group.of_item("paste").ib_enabled = false
// 2.0
uo_ribbon.of_add_tab("home", "Home")
uo_ribbon.of_add_group("home/clip", "Clipboard")
uo_ribbon.of_add_button("home/clip/paste", "Paste", "img/paste.svg")
uo_ribbon.of_item("home/clip/paste").ib_enabled = false
And the event that follows:
// 1.0
event ue_clicked (string as_tab, string as_group, string as_id)
if as_tab = "home" and as_group = "clip" and as_id = "paste" then ...
// 2.0
event ue_clicked (string as_keys)
if as_keys = "home/clip/paste" then ...
Handle properties (ib_enabled, is_text, is_image, ib_visible…) and the property engine are unchanged: what moves is how you reach the handle, not what you do with it.
9.3 The recipe #
- Migrate a copy of your libraries, as for any PowerBuilder version change — see Getting started. Replace
pbtoolboxai.pblwith the 2.0 one. - Run a Full Build. Every call to fix comes out as a compile error, with the object and the script: the list is complete on the first pass, nothing to guess.
- Fix the calls with the tables of section 9.4: a handle that added becomes the component plus the address; an
lnv_x = of_add_…becomes a bare call, and the handle is then taken from the level's getter. - In your event scripts the arguments changed name and number —
as_tab, as_group, as_idbecomeas_keys. PowerBuilder flags each reference to a vanished argument; replace the three-value comparison with an address comparison. - The internal functions renamed to
xx_(of_on_item_property,of_ensure_created,xx_of_send, the handles'of_init) only concern you if you derived a component or a handle and overrode one of them.
9.4 Component by component #
In the tables, lnv_tab, lnv_group, lnv_item, lnv_bar, lnv_section, lnv_tile stand for a 1.0 handle; uo for the component. A quoted address shows the levels expected. Unchanged parameters are shortened to ….
Shared foundation (every component) #
| 1.0 | 2.0 |
|---|---|
uo.of_icon (as_path) · uo.of_escape_markup (as_text) | n_pbt_utils lnv_utils → lnv_utils.of_icon (as_path) · lnv_utils.of_escape_markup (as_text) |
of_on_item_property (as_key[], as_name, as_value) | xx_on_item_property (as_key[], as_name, as_value) |
of_ensure_created ( ) | xx_ensure_created ( ) |
xx_of_send (as_name, as_payload_json) | xx_send (as_name, as_payload_json) |
n_pbt_item.of_init (auo_owner, as_key) | xx_init (auo_owner, as_key) |
| — | of_count ( ) · of_count (as_keys) · of_keys_at (ai_index) · of_keys_at (as_keys, ai_index) · of_has (as_keys) · event ue_script_error (as_message, as_stack) |
Ribbon #
| 1.0 | 2.0 |
|---|---|
lnv_tab = uo.of_add_tab (as_id, as_title) | uo.of_add_tab (as_key, as_title) → long; then uo.of_tab (as_key) |
lnv_tab = uo.of_insert_tab (…) · of_add_contextual_tab (…) · of_add_qat (…) | long ; as_id → as_key, as_group_id → as_group_key |
lnv_ctx = uo.of_add_contextual_group (as_id, as_title { , al_color }) | uo.of_add_contextual_group (as_key, as_title { , al_color }) → long ; uo.of_ctx_group (as_key) |
lnv_ctx.of_add_tab (as_id, as_title) · lnv_ctx.of_tab (as_id) | uo.of_add_contextual_tab (as_key, as_title, as_group_key) · uo.of_tab (as_key) |
lnv_group = lnv_tab.of_add_group (as_id, as_title) | uo.of_add_group ("tab/group", as_title) → long |
lnv_tab.of_group (as_id) · lnv_tab.of_remove_group (as_id) | uo.of_group ("tab/group") · uo.of_remove_group ("tab/group") |
lnv_group.of_add_button (as_id, as_label, as_image) | uo.of_add_button ("tab/group/id", as_label, as_image) → long |
lnv_group.of_add_big_button · of_add_big_split · of_add_big_dropdown · of_add_toggle · of_add_dropdown · of_add_checkbox · of_add_combo · of_add_spinner · of_add_colorpicker · of_add_gallery | same name on uo, first argument "tab/group/id", returns long |
lnv_group.of_add_separator ( ) | uo.of_add_separator ("tab/group") |
lnv_group.of_item (as_id) · lnv_group.of_remove_item (as_id) | uo.of_item ("tab/group/id") · uo.of_remove_item ("tab/group/id") |
lnv_item.of_add_menu_item (as_id, as_label, as_image) | uo.of_add_menu_item ("tab/group/item/id", as_label, as_image) |
lnv_item.of_add_menu_item (as_parent, as_id, as_label, as_image) | uo.of_add_menu_item ("tab/group/item/parent/id", as_label, as_image) |
lnv_item.of_add_menu_separator ( ) · of_add_menu_header (as_label) | uo.of_add_menu_separator ("tab/group/item") · uo.of_add_menu_header ("tab/group/item", as_label) |
lnv_item.of_add_menu_check (as_id, as_label { , as_image }) | uo.of_add_menu_check ("tab/group/item/id", as_label { , as_image }) |
lnv_item.of_add_combo_item (as_label) | uo.of_add_combo_item ("tab/group/combo", as_label) |
lnv_item.of_add_gallery_item (as_id, as_image, as_label) | uo.of_add_gallery_item ("tab/group/gallery/id", as_image, as_label) |
lnv_item.of_menu_item (as_id) | uo.of_menu_item ("tab/group/item/id") |
lnv_item.of_select_item (as_id) | uo.of_select_gallery_item ("tab/group/gallery/id") |
lnv_item.of_open ( ) | uo.of_open ("tab/group/item") |
uo.of_add_app_menu_item (as_parent, as_id, as_label, as_image) | uo.of_add_app_menu_item ("parent/id", as_label, as_image) |
uo.of_add_app_menu_separator (as_id) · of_select_tab (as_id) · of_remove_tab (as_id) | as_id → as_keys / as_key |
event ue_clicked (as_tab, as_group, as_id) | event ue_clicked (as_keys) |
event ue_toggled (as_tab, as_group, as_id, ab_checked) | event ue_toggled (as_keys, ab_checked) |
event ue_menu_selected (as_tab, as_group, as_dropdown, as_id, ab_checked) | event ue_menu_selected (as_keys, ab_checked) |
event ue_combo_changed (as_tab, as_group, as_id, as_text) | event ue_combo_changed (as_keys, as_text) |
event ue_value_changed (as_tab, as_group, as_id, ad_value) | event ue_value_changed (as_keys, ad_value) |
event ue_color_changed (as_tab, as_group, as_id, al_color) | event ue_color_changed (as_keys, al_color) |
event ue_launcher (as_tab, as_group) | event ue_launcher (as_keys) |
event ue_selection_changed (as_id) · ue_app_menu_selected (as_id) | (as_keys) |
event ue_gallery_selection_changed (as_tab, as_group, as_id, as_from_item, as_item) · ue_gallery_selection_changing (…) | (as_from_keys, as_keys) |
Toolbar #
| 1.0 | 2.0 |
|---|---|
lnv_bar = uo.of_add_bar (as_bar { , ai_band, ai_index }) | uo.of_add_bar (as_key { , ai_band, ai_index }) → long; then uo.of_bar (as_key) |
lnv_bar.of_add_button (as_id, as_text, as_image, as_tooltip) | uo.of_add_button ("bar/id", as_text, as_image, as_tooltip) → long |
lnv_bar.of_add_toggle · of_add_dropdown · of_add_label · of_add_textbox · of_add_datepicker · of_insert_button | same name on uo, first argument "bar/id", returns long |
lnv_bar.of_add_separator ( ) | uo.of_add_separator ("bar") |
lnv_bar.of_item (as_id) · of_move_item (as_id, ai_index) · of_remove_item (as_id) | uo.of_item ("bar/id") · uo.of_move_item ("bar/id", ai_index) · uo.of_remove_item ("bar/id") |
lnv_item.of_add_menu_item (as_id, as_label, as_image) | uo.of_add_menu_item ("bar/item/id", as_label, as_image) |
lnv_item.of_add_menu_item (as_parent, as_id, as_label, as_image) | uo.of_add_menu_item ("bar/item/parent/id", as_label, as_image) |
lnv_item.of_add_menu_separator (as_id) | uo.of_add_menu_separator ("bar/item") |
uo.of_bar (as_id) · uo.of_remove_bar (as_id) | as_id → as_key |
event ue_clicked (as_bar, as_id) | event ue_clicked (as_keys) |
event ue_toggled (as_bar, as_id, ab_checked) | event ue_toggled (as_keys, ab_checked) |
event ue_menu_selected (as_bar, as_dropdown, as_id) | event ue_menu_selected (as_keys) |
event ue_text_changed (as_bar, as_id, as_text) · ue_date_changed (as_bar, as_id, as_date) | (as_keys, as_text) · (as_keys, as_date) |
event ue_bar_reordered (as_id, ai_band, ai_index) | event ue_bar_reordered (as_key, ai_band, ai_index) |
Tiles box #
| 1.0 | 2.0 |
|---|---|
lnv_group = uo.of_add_group (as_group_id, as_title) | uo.of_add_group (as_key, as_title) → long; then uo.of_group (as_key) |
lnv_group.of_add_tile (as_id, as_label, as_icon_file, as_size) | uo.of_add_tile ("group/id", as_text { , as_image, as_size }) → long |
lnv_group.of_tile (as_id) | uo.of_tile ("group/id") |
lnv_tile.of_add_live_item (as_text) · lnv_tile.of_clear_live_items ( ) | uo.of_add_live_item ("group/id", as_text) · uo.of_clear_live_items ("group/id") |
uo.of_remove_tile (as_group, as_id) · of_move_tile (as_group, as_id, ai_index) | uo.of_remove_tile ("group/id") · uo.of_move_tile ("group/id", ai_index) |
uo.of_insert_tile (as_group, as_id, as_text { , as_image, as_size }, ai_index) | uo.of_insert_tile ("group/id", as_text { , as_image, as_size }, ai_index) |
uo.of_group (as_id) · uo.of_remove_group (as_id) | as_id → as_key |
event ue_tile_clicked (as_group, as_id) · ue_tile_context (as_group, as_id) | (as_keys) |
event ue_tile_moved (as_group, as_id, as_to_group, al_index) | event ue_tile_moved (as_keys, as_to_keys, al_index) |
event ue_tile_resized (as_group, as_id, as_size) | event ue_tile_resized (as_keys, as_size) |
event ue_group_toggled (as_group, ab_collapsed) | event ue_group_toggled (as_key, ab_collapsed) |
Listbar #
| 1.0 | 2.0 |
|---|---|
lnv_section = uo.of_add_header (as_id, as_text) | uo.of_add_section (as_key, as_text) → long; then uo.of_section (as_key) |
lnv_section.of_add_item (as_id, as_label, as_icon_file) | uo.of_add_item ("section/id", as_text { , as_image }) → long |
lnv_section.of_item (as_id) | uo.of_item ("section/id") |
uo.of_selected_section ( ) | uo.of_selected_key ( ) — the full address, "section/id" |
uo.of_remove_item (as_section, as_id) · of_select_item (as_section, as_id) · of_move_item (as_section, as_id, ai_index) | uo.of_remove_item ("section/id") · uo.of_select_item ("section/id") · uo.of_move_item ("section/id", ai_index) |
uo.of_insert_item (as_section, as_id, as_text { , as_image }, ai_index) | uo.of_insert_item ("section/id", as_text { , as_image }, ai_index) |
uo.of_section (as_id) | uo.of_section (as_key) |
| — | of_insert_section (as_key, as_text, ai_index) · of_remove_section (as_key) · of_move_section (as_key, ai_index) · of_item (…).of_is_selected ( ) |
event ue_selection_changed (as_from_section, as_from_id, as_section, as_id) · ue_selection_changing (…) | (as_from_keys, as_keys) |
event ue_item_reordered (as_section, as_id, ai_index) | event ue_item_reordered (as_keys, ai_index) |
event ue_section_toggled (as_section, ab_collapsed) | event ue_section_toggled (as_key, ab_collapsed) |
Statusbar #
| 1.0 | 2.0 |
|---|---|
uo.of_item (as_id) | uo.of_panel (as_key) |
uo.of_set_panel_menu (as_id, as_item_ids[], as_labels[]) | uo.of_add_menu_item ("panel/id", as_label { , as_image }), one entry per call · of_insert_menu_item ("panel/id", as_label { , as_image }, ai_index) · of_add_menu_separator (as_key) |
uo.of_clear_panel_menu (as_id) | uo.of_clear_menu (as_key) · of_remove_menu_item ("panel/id") · of_move_menu_item ("panel/id", ai_index) |
| — | uo.of_menu_item ("panel/id") → n_pbt_statusbar_menu_item (ib_enabled, ib_checked, ib_visible) |
uo.of_add_panel (as_id, …) · of_insert_panel (as_id, …) · of_remove_panel (as_id) · of_move_panel (as_id, ai_index) · of_flash_panel (as_id, …) | as_id → as_key |
event ue_panel_menu_clicked (as_id, as_item_id) | event ue_panel_menu_clicked (as_keys) — "panel/id" |
event ue_panel_clicked (as_id) · ue_panel_double_clicked (as_id) · ue_panel_rclicked (as_id, al_x, al_y) | as_id → as_key |
Tab #
| 1.0 | 2.0 |
|---|---|
uo.of_item (as_id) | uo.of_page (as_key) |
uo.of_add_page (as_id, …) · of_insert_page (as_id, …) · of_select_page (as_id) · of_remove_page (as_id) · of_refresh_page (as_id) · of_move_page (as_id, ai_index) | as_id → as_key |
event ue_selection_changed (as_from_id, as_id) · ue_selection_changing (…) | (as_from_key, as_key) |
event ue_tab_closed (as_id) · ue_tab_closing (as_id) · ue_tab_reordered (as_id, ai_index) | as_id → as_key |
Dock container #
| 1.0 | 2.0 |
|---|---|
uo.of_item (as_id) | uo.of_panel (as_key) |
Toaster, Statictext, Code editor #
| 1.0 | 2.0 |
|---|---|
n_pbt_toaster : event ue_toast_clicked (as_id) · ue_toast_dismissed (as_id) · ue_toast_action (as_id, as_action) | as_id → as_key |
u_pbt_statictext : event ue_action (as_id) | event ue_action (as_key) |
u_pbt_codeeditor : event ue_changed (as_text) | event ue_changed ( ) — read the text with of_get_text ( ) |
← License and demo mode · Contents · Migrating from 2.0 to 3.0 →