所以我设法自己解决了这个问题。答案是使用所谓的寄存器来标记我们是否传递了当前对象。例如:
lib.menu = HMENU
lib.menu {
1 = TMENU {
NO = 1
NO = {
# Render using Common Object Array (COA)
stdWrap.cObject = COA
stdWrap.cObject {
# Normal Case (However the an item should normally be rendered
10 = TEXT
10 {
if {
isTrue.data = register:cid
value = NORMAL RENDERING
}
}
20 = TEXT
20 {
if {
isTrue.data = register:data
value = RENDERING (IMMEDIATELY) AFTER THE CURRENT ITEM
}
}
# Unset the register (after we've done with our special formatting)
30 = LOAD_REGISTER
30.cid= 0
}
}
...
# The currently selected item
CUR = 1
CUR {
# Render using Common Object Array (COA)
stdWrap.cObject = COA
stdWrap.cObject {
# However the Current item should normally be rendered
10 = TEXT
10.field = title
# Mark that we've reached the current item
20 = LOAD_REGISTER
20.cid= 1
}
}
}
}
使用 LOAD_REGISTER 设置的寄存器基本上是一种运行时变量,可以在遍历菜单项(或其他)的过程中设置和重置。因此,它可以用来记录我们通过菜单项的进度,特别是注意我们是否通过了当前菜单项(CUR)。
rant start 考虑到打字稿是特定领域的语言,它主要用于菜单等规范化的东西,这算不上一个优雅的解决方案。/咆哮结束