Opening Webview from a button click

Hi there…can somebody check my existing code if i miss something important onto it?..i want to show a webview and a website when a button is click…But i cant make it properly…When i tried to bundle my project to an apk and run it on my cp nothig happends…i cant see any webview open and i didnt know why…so i need some guidance from you guys…If anyone who is willing to correct my codes below please make it…Thanks in advance!

local buttonselect

local function webview_callback(self, webview_id, request_id, type, data)
  
  if type == webview.CALLBACK_RESULT_URL_OK then
    self.webview_id = webview.create(webview_callback)
    webview.set_visible(webview_id, 1)
    
  elseif type == webview.CALLBACK_RESULT_URL_ERROR then
    print("Failed to load url: " .. data["url"])
    print("Error: " .. data["error"])
    
  elseif type == webview.CALLBACK_RESULT_EVAL_OK then
    print("Eval ok. Result: " .. data['result'])
    
  elseif type == webview.CALLBACK_RESULT_EVAL_ERROR then
    print("Eval not ok. Request # " .. request_id)
    
  end
end


function init(self)
  msg.post(".","acquire_input_focus")
end


function on_input(self, action_id, action)
  
  if action_id == hash("click") and action.pressed or
  acton_id == hash("touch") and action.pressed then
    
    if gui.pick_node(gui.get_node("buttons1/button_release"),action.x,action.y) then
      gui.set_enabled(gui.get_node("buttons1/button_release"),false)
      gui.set_enabled(gui.get_node("buttons1/button_click"),true)
      buttonselect = "start"
      
    elseif gui.pick_node(gui.get_node("buttons2/button_release"),action.x,action.y) then
      gui.set_enabled(gui.get_node("buttons2/button_release"),false)
      gui.set_enabled(gui.get_node("buttons2/button_click"),true)
      buttonselect = "instructions"
    end
    
  elseif action_id == hash("click") and action.released or acton_id == hash("touch") and action.released then
    gui.set_enabled(gui.get_node("buttons1/button_release"),true)
    gui.set_enabled(gui.get_node("buttons1/button_click"),false)
    gui.set_enabled(gui.get_node("buttons2/button_release"),true)
    gui.set_enabled(gui.get_node("buttons2/button_click"),false)	
    
    if buttonselect == "start" then
      msg.post("main:/category#category","enable")
      msg.post("main:/home_screen#home_screen","disable")
      
    elseif buttonselect == "instructions" then
      local request_id = webview.open(webview_id, "http://www.youtube.com", {hidden = true})
    end
    
  end
  
end
1 Like

It says acton_id instead of action_id when you handle “click”

1 Like