Home / Topic / How to use custom file to for overlaying UI components on other pages

How to use custom file to for overlaying UI components on other pages

Home Kwiksher Forums Kwik4 How to use custom file to for overlaying UI components on other pages

Viewing 1 post (of 1 total)
  • Yamamoto

    these samples reuse the page1 UI components to other pages. commands/page01/*.lua, components/page01/*.lua and components/page01UI.lua are copied and pasted into custom/ folder.

    then use the trick of context switching.


    1)custom page01Contexts loads the page01UI from custom folder and maping for events are redirected to custom.commands.*
      local page01Context = require("custom.contexts.page01Context")
      self:mapMediator("views.page01Scene", "custom.mediators.page01Mediator")
      self:mapCommand("page01.action_act_hide_all", "custom.commands.page01.action_act_hide_all")
    2)in order to make overlay over other pages, page01UI:didShow(params) is added to pageXXXUI.lua of template file
      tmplt/components/pageXXXUI.lua for overlaying page01UI over other pages
      local page01UI = nil
      if UI.curPage ~= 1 then
        page01UI = require("custom.components.page01UI").new(scene)
        page01UI.curPage = {{page}}
        UI = setmetatable( UI, {__index=page01UI})
        UI.layer = setmetatable( UI.layer, {__index=page01UI.layer})
      if page01UI then page01UI:didShow(params) end
    3) custom/components/page01UI.lua
      - page01UI.lua  --  these last parameters are for custom, make it true
        self:_create("common",  const.page_common, true)
        self:_didShow("common",  const.page_common, true)
        self:_didHide("common",  const.page_common, true)
        self:_destroy("common",  const.page_common, true)
      - page01/page_common.lua
      disable preloads at line 50
           -- Preloads next scene. Must be off to use page curl
           -- if not _K.exportCurrent then
           -- _K.timerStash.timer_pl = timer.performWithDelay( 5000, function()
           --    composer.loadScene( "views.page02Scene")
           -- end)
           -- end
        for other files of page01 in custom
      - "page0". .UI.curPage to be "page01" in order to loading it from page2, page3 ..
      preloads disabled
      newImageRect is disabled for other pages
      _AC.Action:playAction("page"..UI.curPage..".action_act_hide_all", params)
      _AC.Action:playAction("page01.action_act_hide_all", params)
    4) how to make sure your custom files are loaded correctly?
       rename or delete original folders such as components/page01, commands/page01
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Privacy Preference Center

Strictly Necessary

these coolies are for WP-SpamShield, gdpr-wp, woocommerce, paypal

PHPSESSID, SJECT16, JCS_INENREF, JCS_INENTIM, gdpr, woocommerce_cart_hash, woocommerce_items_in_cart, woocommerce_recently_viewed, wordpress_, wordpress_logged_in_, wordpress_sec_, wordpress_test_cookie, wp_woocommerce_session_, AKDC, akavpau_ppsd


WordPress cookie created when auto-saving a post in the editor.

wp-saving-post, wp-settings-, wp-settings-time-


google analytic