diff --git a/cwIo.cpp b/cwIo.cpp index 9e551f3..b9ff36a 100644 --- a/cwIo.cpp +++ b/cwIo.cpp @@ -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; diff --git a/cwIo.h b/cwIo.h index ce2fbdd..3c8ea26 100644 --- a/cwIo.h +++ b/cwIo.h @@ -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 ); diff --git a/cwUi.cpp b/cwUi.cpp index 509fbc7..1f636fc 100644 --- a/cwUi.cpp +++ b/cwUi.cpp @@ -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 ) { diff --git a/cwUi.h b/cwUi.h index 7bbf535..08b5bf7 100644 --- a/cwUi.h +++ b/cwUi.h @@ -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 ); diff --git a/html/preset_sel/js/ui.js b/html/preset_sel/js/ui.js index 5d3031d..ba1ddeb 100644 --- a/html/preset_sel/js/ui.js +++ b/html/preset_sel/js/ui.js @@ -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) } }