03.06.2015, 13:53
(
Последний раз редактировалось mk124; 04.06.2015 в 18:41.
)
@dusk:
onClickOk will be called after the "Single action", but also after every other item. It will always be called when you click button0 / enter. If you have a collection of data, I always do it like this:
There are also some other custom types of Dialogs in shoebill-common. For example the PageListDialog, which automatically adds a "<< Next Page <<" and ">> Prev Page >>" (you can change the text) Item to your dialog if there are too many items in one page (also customizable), here is a example:
You can see my project "wl-vehicle-manager", which uses dialog, although it has stopped development:
https://github.com/GTAUN/wl-vehicle-...vehicle/dialog
onClickOk will be called after the "Single action", but also after every other item. It will always be called when you click button0 / enter. If you have a collection of data, I always do it like this:
Код:
Collection<Person> data = new ArrayList<>(); //data from dynamic source ListDialog listDialog = ListDialog.create(player, eventManager) .caption("My dialog with dynamic data") .buttonCancel("Cancel") .buttonOk("Ok") .build(); for(Person person : data) { listDialog.addItem(person.getName(), item -> { //Do things with the person object }); } // check if the listdialog contains data if(listDialog.getItems().size() > 0) listDialog.show(); else player.sendMessage(Color.RED, "* There is no data available!");
Код:
PageListDialog pageListDialog = PageListDialog.create(player, eventManager) .caption("Pagination") .prevPage("<< Previous Page <<") .nextPage(">> Next Page >>") .itemsPerPage(10) .build(); for(int i = 0; i < 50; i++) { pageListDialog.addItem("Item " + i); } pageListDialog.show();
https://github.com/GTAUN/wl-vehicle-...vehicle/dialog