cwUi,cwIo,ui.js : Added ui::setScrollTop()

This commit is contained in:
kevin 2024-05-11 12:10:21 -04:00
parent 4ff1ec578e
commit 8ffc2f3e57
5 changed files with 51 additions and 8 deletions

View File

@ -3765,6 +3765,16 @@ int cw::io::uiGetOrderKey( handle_t h, unsigned uuId )
return orderKey;
}
cw::rc_t cw::io::uiSetScrollTop( handle_t h, unsigned uuId )
{
rc_t rc;
ui::handle_t uiH;
if((rc = _handleToUiHandle(h,uiH)) == kOkRC )
rc = ui::setScrollTop(uiH,uuId);
return rc;
}
cw::rc_t cw::io::uiSetBlob( handle_t h, unsigned uuId, const void* blob, unsigned blobByteN )
{
rc_t rc;

1
cwIo.h
View File

@ -394,6 +394,7 @@ namespace cw
rc_t uiSetOrderKey( handle_t h, unsigned uuId, int orderKey );
int uiGetOrderKey( handle_t h, unsigned uuId );
rc_t uiSetScrollTop( handle_t h, unsigned uuId );
rc_t uiSetBlob( handle_t h, unsigned uuId, const void* blob, unsigned blobByteN );
const void* uiGetBlob( handle_t h, unsigned uuId, unsigned& blobByteN_Ref );

View File

@ -13,12 +13,12 @@
#include "cwUi.h"
#define UI_CLICKABLE_LABEL "clickable"
#define UI_SELECT_LABEL "select"
#define UI_VISIBLE_LABEL "visible"
#define UI_ENABLE_LABEL "enable"
#define UI_ORDER_LABEL "order"
#define UI_CLICKABLE_LABEL "clickable"
#define UI_SELECT_LABEL "select"
#define UI_VISIBLE_LABEL "visible"
#define UI_ENABLE_LABEL "enable"
#define UI_ORDER_LABEL "order"
#define UI_SCROLL_TOP_LABEL "scroll_top"
namespace cw
{
namespace ui
@ -2022,6 +2022,9 @@ int cw::ui::getOrderKey( handle_t h, unsigned uuId )
return rc;
}
cw::rc_t cw::ui::setScrollTop( handle_t h, unsigned uuId )
{ return _setPropertyValue( h, UI_SCROLL_TOP_LABEL,uuId,0); }
cw::rc_t cw::ui::setBlob( handle_t h, unsigned uuId, const void* blob, unsigned blobByteN )
{

4
cwUi.h
View File

@ -150,6 +150,10 @@ namespace cw
rc_t setOrderKey( handle_t h, unsigned uuId, int orderKey );
int getOrderKey( handle_t h, unsigned uuId );
// Scroll the element identified by 'uuId' to the top of the list.
// (uuId must identify a list element whose parent is a 'uiList')
rc_t setScrollTop( handle_t h, unsigned uuId );
rc_t setBlob( handle_t h, unsigned uuId, const void* blob, unsigned blobByteN );
const void* getBlob( handle_t h, unsigned uuId, unsigned& blobByteN_Ref );
rc_t clearBlob( handle_t h, unsigned uuId );

View File

@ -120,7 +120,6 @@ function ui_send_string_value( ele, value ) { ui_send_value(ele,'s',value); }
function ui_send_click( ele )
{
//console.log("click " + ele.id )
ws_send("click " + ele.id )
}
@ -907,7 +906,30 @@ function ui_set_order_key(ele, orderKey)
// no element was found greater than this element ....
if( i == parent.children.length )
parent.appendChild(ele) // ... insert the element at the end of the child lsit
parent.appendChild(ele) // ... insert the element at the end of the child lsit
}
function ui_scroll_top(ele)
{
/*
var rect = ele.getBoundingClientRect();
var prect = ele.parentElement.getBoundingClientRect();
console.log(ele.id, rect.top, rect.right, rect.bottom, rect.left, ele.offsetTop);
console.log(prect.top, prect.right, prect.bottom, prect.left );
var scr_ele = document.getElementById(42408)
var sr = scr_ele.getBoundingClientRect()
console.log(sr.top, sr.right, sr.bottom, sr.left, scr_ele.offsetTop);
ele.parentElement.scrollTop = sr.top - prect.top
console.log(sr.top, sr.right, sr.bottom, sr.left, scr_ele.offsetTop);
*/
var er = ele.getBoundingClientRect()
var pr = ele.parentElement.getBoundingClientRect()
ele.parentElement.scrollTop = er.top - pr.top
}
@ -950,6 +972,9 @@ function ui_set( d )
case "order":
ui_set_order_key(ele,d.value)
break
case "scroll_top":
ui_scroll_top(ele)
}
}