local UIBulletChatPanel = UIViewClass() local EventSystem = require("Event/EventSystem") function UIBulletChatPanel:OnOpened(context) self.wordLimit = context.wordLimit or DataSheetManager.ConstData:GetDataByID("TLBulletWordNum").IntValue self.loop_Emoji:ReloadAll(MDL.ChannelChat.GetSortedEmojiList()) UIUtils.SetActive(self.group_Emoji, false) UIUtils.SetActive(self.btn_Bottom, false) self:OnButtonClicked(self.event_Close) end function UIBulletChatPanel:OnButtonClicked(comp) if comp == self.event_Send then self:SendBulletMsg(self.obj_InputField.text) elseif comp == self.event_Open then self.state_Btn:SetState(1) CTL.BulletScreen.Hide() elseif comp == self.event_Close then self.state_Btn:SetState(0) CTL.BulletScreen.Show() elseif comp == self.btn_Bottom then UIUtils.SetActive(self.group_Emoji, false) UIUtils.SetActive(self.btn_Bottom, false) elseif comp == self.event_Emoji then local active = not self.group_Emoji.gameObject.activeInHierarchy UIUtils.SetActive(self.group_Emoji, active) UIUtils.SetActive(self.btn_Bottom, active) end end function UIBulletChatPanel:SendBulletMsg(content) if not CTL.BulletScreen.IsOutOfLength(content, self.wordLimit) then EventSystem.Dispatch(EventID.UI_BulletScreen_TimeLineSendReq, content) self.obj_InputField.text = "" end end function UIBulletChatPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Emoji then cellTable.txt_emoji.text = "[" .. data.ID .. "]" end end function UIBulletChatPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Emoji then self:OnCommonClickEmoji(data) end end function UIBulletChatPanel:OnCommonClickEmoji(data) local emojiShow = string.format("[%s]", UIUtils.GetLocalizedTxt(Const_IDS[data.EmojiName])) local msg = self.obj_InputField.text if not CTL.BulletScreen.IsOutOfLengthWhenInsertContent(msg .. emojiShow, self.wordLimit) then msg = msg .. emojiShow self:SetInputTextAndMoveEnd(msg) end end function UIBulletChatPanel:SetInputTextAndMoveEnd(txt) self.obj_InputField.text = txt self.obj_InputField:ActivateInputField() --光标移动需要激活之后等一帧生效 self:StartRepeatFunc(self.MoveToTextEnd, 0.02, 1) end function UIBulletChatPanel:MoveToTextEnd() self.obj_InputField:MoveTextEnd(false) self.obj_InputField:DeactivateInputField() end return UIBulletChatPanel