Hey guys!
I've been getting requests on a written tutorial on popup windows and I wanted to finally do it! Remember that this is not all Javascript and I do recommend learning Java first before starting any UI stuff. Anyways, let's get started.
First decide how you want to activate this. Tap on a certain block? Button? Any way will work!
For now we are going to use the useItem() hook for this.
Now, let's start by defining the dialog and the layout. You may use the addView method to add any other views to your layout (Buttons, TexViews, EditTexts, etc...)
function useItem(x, y, x, itemId, blockId){
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
if(itemId == 280){//If the item you are holding is a stick
ctx.runOnUiThread(new java.lang.Runnable(){//Define a new Ui Thread
run: function(){
try{
var dialog = new android.app.Dialog(ctx);//Dialog that will pop up
var layout = new android.widget.LinearLayout(ctx);//Layout that will hold all views
var tv = new android.widget.TextView(ctx);//The view that will display text
}catch(e){
print("Error: " + e);
}
}
});
}
}
Now that you have the objects defined let's put them all in the dialog!
function useItem(x, y, x, itemId, blockId){
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
if(itemId == 280){//If the item you are holding is a stick
ctx.runOnUiThread(new java.lang.Runnable(){//Define a new Ui Thread
run: function(){
try{
var dialog = new android.app.Dialog(ctx);//Dialog that will pop up
var layout = new android.widget.LinearLayout(ctx);//Layout that will hold all views
var tv = new android.widget.TextView(ctx);//The view that will display text
tv.setText("This dialog was opened!");//Add text to the text view
layout.addView(tv);//Add the textview to the layout
dialog.setContentView(layout);//Sets the content of the dialog to a specified layout
}catch(e){
print("Error: " + e);
}
}
});
}
}
Ok, let's customize the dialog and show it off!
function useItem(x, y, x, itemId, blockId){
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
if(itemId == 280){//If the item you are holding is a stick
ctx.runOnUiThread(new java.lang.Runnable(){//Define a new Ui Thread
run: function(){
try{
var dialog = new android.app.Dialog(ctx);//Dialog that will pop up
var layout = new android.widget.LinearLayout(ctx);//Layout that will hold all views
var tv = new android.widget.TextView(ctx);//The view that will display text
tv.setText("This dialog was opened!");//Add text to the text view
tv.setTextColor(android.graphics.Color.GREEN);//Text color is set to green
layout.addView(tv);//Add the textview to the layout
layout.setBackgroundColor(android.graphics.Color.RED);//Sets the background color to red
dialog.setContentView(layout);//Sets the content of the dialog to a specified layout
dialog.setTitle("Dialog");//Sets a title
dialog.show();//Show off your masterpiece!
}catch(e){
print("Error: " + e);
}
}
});
}
}
Hope this helped some people!
Anymore requests would be great!
Great job! Maybe you could include customising the placement of the button for some people? Also can you please include how to make a button show more buttons when it is pressed? I know how to make more buttons appear temporarily, but I don't know how to customise the position of each temporary button. If possible, could you PM me a script template which would be able to do this?
Hey guys!
I've been getting requests on a written tutorial on popup windows and I wanted to finally do it! Remember that this is not all Javascript and I do recommend learning Java first before starting any UI stuff. Anyways, let's get started.
First decide how you want to activate this. Tap on a certain block? Button? Any way will work!
For now we are going to use the useItem() hook for this.
Now, let's start by defining the dialog and the layout. You may use the addView method to add any other views to your layout (Buttons, TexViews, EditTexts, etc...)
Now that you have the objects defined let's put them all in the dialog!
Ok, let's customize the dialog and show it off!
Anymore requests would be great!
I'm glad I could help
Link Removed
Link Removed
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]
Thanks!
~MattdaveMatt
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]