Skip to content

Commit

Permalink
Merge pull request #922 from AntlerForce/defaultBattleTitle
Browse files Browse the repository at this point in the history
When editing battle title, use the current title as defaultValue
  • Loading branch information
AntlerForce authored Feb 27, 2025
2 parents a7eda6b + 5d7a682 commit 3a555e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions LuaMenu/widgets/gui_battle_room_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3064,15 +3064,18 @@ local function InitializeControls(battleID, oldLobby, topPoportion, setupData)
if battleLobby.name ~= "singleplayer" then
if WG.TextEntryWindow then
WG.TextEntryWindow.CreateTextEntryWindow({
defaultValue = "",
defaultValue = battleTitle:gsub("(.*)|.*$", "%1"):gsub("%s*$", ""),
caption = i18n("rename_battle"),
labelCaption = i18n("rename_caption"),
hint = i18n("rename_hint"),
height = 280,
width = 480,
width = 550,
oklabel = i18n("rename"),
OnAccepted = function(newname)
lobby:SayBattle("!rename " .. newname)
end,
OnOpen = function(editBox)
editBox:SelectAll()
end
})
end
Expand Down
3 changes: 3 additions & 0 deletions LuaMenu/widgets/gui_textentry_popup_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ local function CreateTextEntryWindow(opts)
},
}

if opts.OnOpen then
opts.OnOpen(eb)
end

WG.Chobby.PriorityPopup(TextEntryWindow, CloseFunction, CloseFunction, screen0, nil, opts.disableAcceptHotkey)

Expand Down
9 changes: 9 additions & 0 deletions libs/chiliui/chili/controls/editbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -980,4 +980,13 @@ function EditBox:TextEditing(utf8, start, length)
return true
end

function EditBox:SelectAll()
if not self.multiline then
self:_SetSelection(1, 1, #self.text + 1, 1)
else
self:_SetSelection(1, 1, #self.lines[#self.lines].text + 1, #self.lines)
end
self:Invalidate()
end

--// =============================================================================

0 comments on commit 3a555e0

Please sign in to comment.