@@ -146,6 +146,7 @@ class MPage extends VList<MItem,MItemData>
146
146
// Set data and init the items
147
147
setDataSource (page .items );
148
148
149
+
149
150
// :: NEW : All cursor logic is in its own place
150
151
// TODO, Cache the cursor object to be reusable?
151
152
if (STP .cursor != null )
@@ -221,18 +222,24 @@ class MPage extends VList<MItem,MItemData>
221
222
}
222
223
}// ---------------------------------------------------;
223
224
224
- // Initializes the emenu, and focuses the first available
225
+ /**
226
+ - Called whenever a page is shown normally (i.e. not when going back to it)
227
+ - Initializes the menu and focuses an item (first selectable, or custom autofocus)
228
+ **/
225
229
public function selectFirstAvailable ()
226
230
{
227
- setSelection (get_nextSelectableIndex (0 , 1 ));
231
+ var ind = page .getAutofocus ();
232
+ if (ind < 0 ) ind = get_nextSelectableIndex (0 , 1 );
233
+ setSelection (ind );
228
234
}// ---------------------------------------------------;
229
235
230
236
231
- /** Focus an item, Moves the cursor to that item, scrolls the view if needed
237
+ /** Focuses an item (moves the cursor to that item and item gets highlighted)
238
+ Hard-scrolls the view if needed
232
239
@param id ID of the Item
233
240
@return Success
234
241
**/
235
- public function item_moveCursorTo (id : String ): Bool
242
+ public function item_focus (id : String ): Bool
236
243
{
237
244
var i = page .getIndex (id );
238
245
if (i > - 1 ){
@@ -277,12 +284,14 @@ class MPage extends VList<MItem,MItemData>
277
284
278
285
}// ---------------------------------------------------;
279
286
280
- /** Get the current active item data the cursor is pointing
287
+ /**
288
+ * ~ NEW in 0.5.8. BREAKING CHANGES : This now returns items, not itemdata
289
+ * ~ to get itemdata, simple do item_getCurrent().data;
290
+ * Get the current item the cursor is pointing
281
291
*/
282
- public function item_getCurrent (): MItemData
292
+ public function item_getCurrent (): MItem
283
293
{
284
- if (indexData < 0 ) return null ;
285
- return data [indexData ];
294
+ return indexItem ;
286
295
}// ---------------------------------------------------;
287
296
288
297
0 commit comments