@@ -309,6 +309,14 @@ static void Slider_OnMouseDown( LCUI_Widget slider,
309
309
Widget_BindEvent ( slider , "mouseup" , Slider_OnMouseUp , w , NULL );
310
310
}
311
311
312
+ static void ScrollBar_OnLink ( LCUI_Widget w , LCUI_WidgetEvent e , void * arg )
313
+ {
314
+ LCUI_ScrollBar scrollbar = Widget_GetData ( w , self .prototype );
315
+ if ( !scrollbar -> box ) {
316
+ ScrollBar_BindBox ( w , w -> parent );
317
+ }
318
+ }
319
+
312
320
static void ScrollBar_OnInit ( LCUI_Widget w )
313
321
{
314
322
LCUI_Widget slider ;
@@ -329,9 +337,9 @@ static void ScrollBar_OnInit( LCUI_Widget w )
329
337
InitInertialScrolling ( & scrollbar -> effect );
330
338
Widget_BindEvent ( slider , "mousedown" ,
331
339
Slider_OnMouseDown , w , NULL );
340
+ Widget_BindEvent ( w , "link" , ScrollBar_OnLink , NULL , NULL );
332
341
Widget_AddClass ( slider , "scrollbar-slider" );
333
342
Widget_Append ( w , slider );
334
- ScrollBar_BindBox ( w , w -> parent );
335
343
}
336
344
337
345
static void ScrollBar_UpdateSize ( LCUI_Widget w )
@@ -493,8 +501,10 @@ void ScrollBar_BindBox( LCUI_Widget w, LCUI_Widget box )
493
501
ScrollBar_OnUpdateSize );
494
502
}
495
503
scrollbar -> box = box ;
496
- Widget_BindEvent ( box , "resize" , ScrollBar_OnUpdateSize , w , NULL );
497
- Widget_BindEvent ( box , "setscroll" , ScrollBar_OnSetPosition , w , NULL );
504
+ if ( box ) {
505
+ Widget_BindEvent ( box , "resize" , ScrollBar_OnUpdateSize , w , NULL );
506
+ Widget_BindEvent ( box , "setscroll" , ScrollBar_OnSetPosition , w , NULL );
507
+ }
498
508
ScrollBar_UpdateSize ( w );
499
509
}
500
510
0 commit comments