While I was developing an application on Code Name One on the simulator I faced strange problem.
I have a Tabs
with a single Tab
, this tab has a browserComponent
with HTML content. It has span
element which call a JavaScript function onclick
event, this JavaScript function call a Java method which create a new Tab
and add it to the Tabs
.
Everything at this moment goes well, but the BrowserComponent
starts loading the CodeNameONe
home page by itself without any instruction from me, so I was wondering if it's a bug or what. I'm using NetBeans 8.2 with the last version of CodeNameOne
.
NOTE I called a Java method from JS function in another example with on Tabs
and the browser didn't load any external pages so I think is related to Tabs
more than any thing else.
NOTE I am sure no problem related to the code but I posted it after being advised to do so.
This is the JavaScript function:
function openMessageFaceJS()
{
window.openMessageFace();
}
and this is the Java method
this.context.getWindow().//context is a JSObject
set("openMessageFace", (JSFunction) (who, are_you) ->
{
manager.openMessageFace();
//look blow to see this method openMessageFace();
});
And in another class the actual method code
public void openMessageFace()
{
//this operation is performed successfuly
Component component = create1();
tabs.addTab("what (:", component);
sendMessageFacePosotiin = tabs.getTabCount() - 1;
tabs.setSelectedIndex(sendMessageFacePosotiin, true);
}