-
Notifications
You must be signed in to change notification settings - Fork 2
Modal Form
ClickedTran_VN edited this page Jul 22, 2024
·
2 revisions
According to the introduction at HOME, this is the second menu type of the three, and is also the easiest menu to make but unlike NORMAL_FORM
, MODAL_FORM
only has 2 functions (image
is not supported), Besides that, the code has not changed at all
You can refer to here:
use pocketmine\player\Player;
use venndev\vformoopapi\Form;
use venndev\vformoopapi\attributes\VForm;
use venndev\vformoopapi\attributes\modal\VButton;
use vennvdev\vformoopapi\utils\TypeForm;
#[VForm(
title: "Your Menu Title",
type: TypeForm::MODAL_FORM,
content: "Your Menu Content"
)]
final class YourClass extends Form{
public function __construct(Player $player){
parent::__construct($player);
$this->setContent("This is example for Modal Form"); //<-- This is the content at 'content' before the class
}
#[VButton(
text: "Your Text" //Button1
)]
public function YourTextFunction(Player $player, mixed $data) : void{
$player->sendMessage("You have pressed button 1");
}
#[VButton(
text: "Your Text 2" //Button2
)]
public function YourFunction(Player $player, mixed $data) : void{
$player->sendMessage("You pressed button 2!");
}
public function onClose(Player $player) : void{
$player->sendMessage("You have closed the menu");
}
}
- NOTE:
- You need to do something like
Example Code
for the menu to work#[VButton()]
=>Create button for menu
#[VForm()]
=>Create new menu