diff --git a/tutorials/touchpriority.md b/tutorials/touchpriority.md index ff9dd04..5260499 100644 --- a/tutorials/touchpriority.md +++ b/tutorials/touchpriority.md @@ -22,18 +22,16 @@ There are two values related to force priority: `forcePrio` and `targetPrio` Force priority tracks the current force priority applied to the popup. Popups (mainly `FLAlertLayer` but other popups do it as well) change this value to set the current force priority. It starts from -500 with a single popup, and decreases by 2 for each consequent popup. -Target priority tracks the target priority that should apply to normal utilities such as `CCTextInputNode` or `SliderTouchLogic` (but not `CCMenu`). If the touch priority requested by these classes are bigger value than the target priority, they are set to the target priority instead. Target priority values are the same as the force priority values. +Target priority tracks the target priority that should apply to layers such as `CCTextInputNode` or `SliderTouchLogic` and `CCMenu`. If the touch priority requested by these classes are bigger value than the target priority, they are set to the target priority instead. Target priority values are the same as the force priority values. -Robtop has 3 main functions for dealing with force priority: `CCTouchDispatcher::registerForcePrio`, `CCTouchDispatcher::unregisterForcePrio`, `CCTouchDispatcher::addPrioTargetedDelegate`. Registering decreases the target priority, unregistering increases the target priority. Adding a prio targeted delegate allows the layer to use the target priority value instead of the requested touch priority. +Robtop has 3 main functions for dealing with force priority: `CCTouchDispatcher::registerForcePrio`, `CCTouchDispatcher::unregisterForcePrio`, `CCTouchDispatcher::addPrioTargetedDelegate`. Registering decreases the target priority, unregistering increases the target priority. Adding a prio targeted delegate allows the layer to use the target priority decreased by 1 if force priority is active. ## How to use it myself If you're not dealing with any popups, chances are you don't need to deal with any of these either. But if you are, you should follow these guidelines. -If your popup subclasses `geode::Popup<>`, the registering and unregistering is handled automatically. The class also uses the `geode::cocos::handleTouchPriority` utility, which recursively sets the priorities of every children a lower value than itself, handling the cases like adding `CCMenu`'s, which Robtop does not use the prio targeted delegate for. +If your popup subclasses `geode::Popup<>`, the registering and unregistering is handled automatically. -If you're adding new touch layers after the initiation has been done, you can again call `geode::cocos::handleTouchPriority` for redoing the touch priorities for the new layers. +If you're not using `geode::Popup<>` class and directly subclassing `FLAlertLayer` instead, you should call `FLAlertLayer::init(int opacity)` inside your init. This will handle the registering of the force priority, along with creating the `m_mainLayer`. You should also override `registerWithTouchDispatcher` and call `CCTouchDispatcher::addTargetedDelegate` in it, since that will allow you to register the popup not as a prio targeted delegate. If you leave it the default, `FLAlertLayer` will have one less priority than your layers (-503 vs -502), meaning none of the touches will go to your layers since they will be consumed. And lastly, `~FLAlertLayer` handles unregistering of the force priority. -If you're not using `geode::Popup<>` class and directly subclassing `FLAlertLayer` instead, you should call `FLAlertLayer::init(int opacity)` inside your init. This will handle the registering of the force priority, along with creating the `m_mainLayer`. The `FLAlertLayer::registerWithTouchDispatcher` handles the delegate, and `~FLAlertLayer` handles unregistering of the force priority. - -If you don't want to use the geode utility and set the priorities manually, you can call `CCLayer::setTouchPriority`/`CCMenu::setHandlerPriority` on your layer with the `CCTouchDispatcher::getTargetPrio` value. \ No newline at end of file +If you want to set the priorities manually (such as for an overlay), you can call `CCLayer::setTouchPriority`/`CCMenu::setHandlerPriority` on your layer with the `CCTouchDispatcher::getTargetPrio` value. \ No newline at end of file