ianharrigan / haxeui

IMPORTANT NOTE! This repository is no longer maintained. Please consider the newer version: https://github.com/haxeui/haxeui-core
http://haxeui.org/
392 stars 46 forks source link

Popup and custom buttons #360

Closed DrDerico closed 8 years ago

DrDerico commented 8 years ago

Hi!

When I add custom buttons to the config for building Popup, their callbacks don't invoke. For example:

showPopup("CONTENT", null, { useDefaultTitle:false, buttons:[new PopupButtonInfo(PopupButton.CUSTOM, "AAA", onDeleteTabConfirmedAAA), new PopupButtonInfo(PopupButton.CUSTOM, "BBB")] }, onDeleteTabConfirmed);

So, onDeleteTabConfirmedAAA doesn't invoke. I didn't see in haxeui source code any line, that makes deal with PopupButtonInfo "_fn" variable.

ianharrigan commented 8 years ago

Yeah, it doesnt seem to be used anywhere, you are right. One thing though i have noticed is you are using PopupButtonInfo and i cant see anywhere that is an input option in: https://github.com/ianharrigan/haxeui/blob/master/haxe/ui/toolkit/core/PopupManager.hx#L269

One thing to try is:

buttons:[{text: "AAA", fn: onDeleteTabConfirmedAAA}, {text: "BBB"}]

ie, use objects rather than PopupButtonInfo

ianharrigan commented 8 years ago

As well as the method above can you pull latest from haxelib (1.8.21) and try that? Ive added a fix there that should invoke the .fn when the button is clicked.

DrDerico commented 8 years ago

Ok, I'll try it tomorrow! Thank you very much!!!

DrDerico commented 8 years ago

It works! But if you use objects, you should write code in this way:

buttons:[{text: "AAA", fn: onDeleteTabConfirmedAAA}, {text: "BBB", fn: null}]

So all objects must contain the same fields, otherwise compiler gives an error message

ianharrigan commented 8 years ago

Right, gotcha... Good to know! Thanks.