@@ -62,6 +62,8 @@ function Window.new(params)
6262 self ._widgetBlockedRegions = {}
6363 -- Initialize click shapes for precise hit testing
6464 self ._clickShapes = {}
65+ -- Flag to prevent focus changes during popup interactions
66+ self ._preventFocusChange = false
6567 self ._requestedNextLineSpacing = nil
6668 return self
6769end
219221--- @param y number Y coordinate
220222--- @return boolean
221223function Window :ShouldChangeFocus (x , y )
222- local _ , shapeData = self :GetClickShapeAt (x , y )
223- return shapeData and shapeData .focusWeight > 0
224+ -- If flag is set, prevent focus changes (used during popup interactions)
225+ if self ._preventFocusChange then
226+ return false
227+ end
228+
229+ -- Check if point is in any popup region
230+ if self ._widgetBlockedRegions then
231+ for _ , region in ipairs (self ._widgetBlockedRegions ) do
232+ if x >= region .x and x <= region .x + region .w and y >= region .y and y <= region .y + region .h then
233+ return false -- Don't change focus if clicking popup area
234+ end
235+ end
236+ end
237+
238+ return true -- Allow focus change for regular window areas
224239end
225240
226241--- Get the focus weight of a click shape at a point
@@ -303,27 +318,6 @@ function Window:resetCursor()
303318 self .H = Globals .Defaults .DEFAULT_H
304319 -- Clear sector sizes to allow sectors to shrink each frame
305320 self ._sectorSizes = {}
306-
307- -- Register main window click shapes
308- local titleHeight = Globals .Defaults .TITLE_BAR_HEIGHT
309-
310- -- Title bar - high focus weight for dragging
311- self :AddClickShape (" title_bar" , {
312- type = " rectangle" ,
313- x = self .X ,
314- y = self .Y ,
315- w = self .W ,
316- h = titleHeight ,
317- }, 2 , { type = " title_bar" })
318-
319- -- Content area - normal focus weight
320- self :AddClickShape (" content_area" , {
321- type = " rectangle" ,
322- x = self .X ,
323- y = self .Y + titleHeight ,
324- w = self .W ,
325- h = self .H ,
326- }, 1 , { type = " content_area" })
327321end
328322
329323return Window
0 commit comments