“This is the fourth day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

First, FGui

Please refer to the official FGUI documentation for explanation. www.fairygui.com/

FGUI screenshot;

Two: Lua part

Base classes View and Component. LuaTools is a tool class for connecting c# and lua. Lua main interface script; Script binding to the page main element. ActivityList_control theme script. ActivityItem_control Theme Item script. IndicatorList_control indicator script. IndeicatorItem_control Indicator Item script.

2.1. Realize the sliding of listening Glist

Self. ActicityList. ScrollPane. OnScrollEnd: Add (function (self) : onScrollEndAction () end) - glist sliding detection, Function ActivityList_control: onScrollEndAction () if self. ActicityList. The scrollPane. PageMode then - whether to paging mode - for current page Local deltaPos = self. ActicityList. The scrollPane. CurrentPageX - acquiring local indicator change indicator indicating state indicatorList = self:GetView().indicatorList_control.indicatorList indicatorList.selectedIndex = deltaPos end endCopy the code

2.2. Implement listening for Glist Item click events

Self. IndicatorList. OnClickItem: Add (function (context) self: onClickItemAction (context) end) - item the click event of the function indicatorList_control:onClickItemAction(context) -- EventContext local a = Self. IndicatorList: GetChildIndex (context data) - get a display object index - conversion display object index index to the project. local itemIndex = self.indicatorList:ChildIndexToItemIndex(a); Local acticityList = self:GetView().itemList_Control.acticityList acticityList.scrollPane:SetCurrentPageX(itemIndex,true) endCopy the code

extension

1. Understanding of indexes in Glist

1, Item index ==Item index 2. Display the index of the object.

Example: add we now have 100 entries, 10 entries per page, and now page 3 is displayed, so the item index of the first element on page 3 is 31, and the index of the display object is 1.

Conversion of two indexes;

The item index is converted to the index of the display object

int childIndex = aList.ItemIndexToChildIndex(1);

Display index is converted to item index

int itemIndex = aList.ChildIndexToItemIndex(1);

General use; Gets the index of the currently displayed object, then converts it to the item index, and then fetches the corresponding data operation.

A solution to event penetration

If BButton on AButton, reference FGUI event mechanism www.fairygui.com/docs/guide/…

Abutton.onClick:Add(function (context) Context :StopPropagation() endCopy the code