1
1
Fork 0
mirror of https://github.com/FellippeHeitor/InForm.git synced 2025-01-14 19:49:33 +00:00

Improved deletion of selected controls when they have children.

This commit is contained in:
FellippeHeitor 2018-09-16 19:10:23 -03:00
parent 2f78b98398
commit b7e9c61b7c
2 changed files with 31 additions and 19 deletions

View file

@ -4752,6 +4752,13 @@ SUB __UI_DestroyControl (This AS __UI_ControlTYPE)
__UI_ParentDropdownList = 0
END IF
ELSEIF This.Type = __UI_Type_MenuPanel THEN
FOR i = 1 TO UBOUND(Control)
IF Control(i).MenuPanelID = This.ID THEN
IF Control(i).ControlIsSelected THEN
Control(i).ControlIsSelected = False
END IF
END IF
NEXT
IF Control(This.SourceControl).Type = __UI_Type_ContextMenu THEN
__UI_ActiveMenuIsContextMenu = False
END IF

View file

@ -1935,20 +1935,33 @@ SUB SelectAllControls
END IF
END SUB
SUB SelectChildrenControls (id AS LONG)
DIM i AS LONG
FOR i = 1 TO UBOUND(Control)
IF Control(i).ParentID = id THEN
IF Control(i).ControlIsSelected = False THEN
Control(i).ControlIsSelected = True
__UI_TotalSelectedControls = __UI_TotalSelectedControls + 1
IF Control(i).Type = __UI_Type_MenuItem THEN
'Recursively select children's children too:
SelectChildrenControls Control(i).ID
END IF
END IF
END IF
NEXT
END SUB
SUB DeleteSelectedControls
DIM i AS LONG, j AS LONG, didDelete AS _BYTE
'A frame's contents will be deleted with it if it's
'A container's contents will be deleted with it if it's
'the only selected control.
IF __UI_TotalSelectedControls = 1 AND Control(__UI_FirstSelectedID).Type = __UI_Type_Frame THEN
FOR i = 1 TO UBOUND(Control)
IF Control(i).ParentID = __UI_FirstSelectedID THEN
IF Control(i).ControlIsSelected = False THEN
Control(i).ControlIsSelected = True
__UI_TotalSelectedControls = __UI_TotalSelectedControls + 1
END IF
END IF
NEXT
IF __UI_TotalSelectedControls = 1 AND _
(Control(__UI_FirstSelectedID).Type = __UI_Type_Frame OR _
Control(__UI_FirstSelectedID).Type = __UI_Type_MenuBar OR _
Control(__UI_FirstSelectedID).Type = __UI_Type_MenuItem OR _
Control(__UI_FirstSelectedID).Type = __UI_Type_ContextMenu) THEN
SelectChildrenControls __UI_FirstSelectedID
END IF
'Iterate over control list and delete selected controls.
@ -1962,11 +1975,6 @@ SUB DeleteSelectedControls
ELSE
MustRefreshContextMenus = True
END IF
FOR j = 1 TO UBOUND(Control)
IF Control(j).ParentID = i THEN
__UI_DestroyControl Control(j)
END IF
NEXT
END IF
IF __UI_TotalActiveMenus > 0 AND __UI_ParentMenu(__UI_TotalActiveMenus) = Control(i).ID THEN
__UI_CloseAllMenus
@ -1975,13 +1983,10 @@ SUB DeleteSelectedControls
IF MustRefreshMenuBar THEN __UI_RefreshMenuBar
IF MustRefreshContextMenus THEN RefreshContextMenus
__UI_ForceRedraw = True
__UI_TotalSelectedControls = __UI_TotalSelectedControls - 1
didDelete = True
END IF
NEXT
IF didDelete THEN
IF __UI_TotalSelectedControls > 0 THEN __UI_TotalSelectedControls = 0
END IF
IF didDelete THEN __UI_TotalSelectedControls = 0
END SUB
SUB RefreshContextMenus