Revision: 4536 http://sourceforge.net/p/vexi/code/4536 Author: clrg Date: 2013-07-16 22:53:04 +0000 (Tue, 16 Jul 2013) Log Message: ----------- Datefield fixes - yearfield 'enter' initialized as YQ - datefield +/- made like other datefields - datefields could get stuck displaying typed text by typing then using datepicker
Modified Paths: -------------- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datefield.t branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/monthfield.t branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/quarterfield.t branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/yearfield.t Modified: branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datefield.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datefield.t 2013-07-03 19:25:17 UTC (rev 4535) +++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/datefield.t 2013-07-16 22:53:04 UTC (rev 4536) @@ -1,6 +1,6 @@ <!-- Copyright 2013 - see COPYING for details [LGPL] --> -<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" +<vexi xmlns:ui="vexi://ui" xmlns:conf="vexi.conf" xmlns:lib="org.vexi.lib" xmlns:lay="vexi.layout" @@ -18,11 +18,11 @@ </ui:box> <lay:pad orient="vertical" padding="3" shrink="true"> <ui:box id="dateview"> - <util:digit id="day" /> + <util:digit id="day" period="day" /> <util:digit id="sep1" fieldsize="1" text="/" /> - <util:digit id="month" /> + <util:digit id="month" period="month" /> <util:digit id="sep2" fieldsize="1" text="/" /> - <util:digit id="year" fieldsize="4" /> + <util:digit id="year" fieldsize="4" period="year" /> </ui:box> <ui:box id="editview" display="false"> <lib:text.default id="edit" textalign="left" /> @@ -41,7 +41,7 @@ <ui:box id="datepicker" /> </lay:border> - thisbox.datepick = $datepicker; + thisbox.datepicker = $datepicker; thisbox.dateview = $dateview; thisbox.dayview = $day; thisbox.monthview = $month; @@ -56,27 +56,23 @@ thisbox.v_popbox = $popbox; thisbox.v_textbox = false; - //////// - // internal behaviour + thisbox.text ++= static.textRead; + thisbox.text ++= static.textWrite; - thisbox.day ++= static.basicWrite; - thisbox.month ++= static.basicWrite; - thisbox.year ++= static.basicWrite; + thisbox.value; ///> vexi.js.Date + + thisbox.value ++= function(v) { + cascade = v; + // value has changed; reject text input + $editview.display = false; + //assert(v===null or v instanceof "date"); + $day.text = v?.day; + $month.text = v?.month; + $year.text = v?.year; + } - thisbox.text ++= static.textRead; - thisbox.text ++= static.textWrite; - thisbox.value ++= static.valueRead; - thisbox.value ++= static.valueWrite; - thisbox.viewsep ++= static.viewsepWrite; - thisbox.textformat ++= static.textformatWrite; - thisbox.valueformat ++= static.valueformatWrite; - thisbox.valueformat = conf.settings..date_valueformat; - thisbox.valueseparator = "-"; - thisbox.textformat = conf.settings..date_textformat; - thisbox.textseparator = "/"; - //////// // button actions @@ -89,71 +85,36 @@ $month.Press1 ++= selectPart; $year.Press1 ++= selectPart; - var setToday = function() { - date = vexi.date(); - } - - $more.action ++= function(v) { - if (year == null) { - setToday(); - } else if (selected == $day) { - if (month==null) { - month = 1; - } - day = day==null ? 1 : day+1; - } else if (selected == $month) { - month = month==null ? 1 : month+1; - } else if (selected == $year) { - year = year+1; - } - value = value; + var incrementTrap = function(v) { + if (selected==null || value==null) return; + var amount = trapee==$more?1:-1; + var period = selected.period; + value = value.addPeriod(period, amount); return; - } + }; - $less.action ++= function(v) { - if (year == null) { - setToday(); - } else if (selected == $day) { - if (month==null) { - month = 12; - } - day = day==null ? monthdays : day-1; - } else if (selected == $month) { - month = month==null ? 12 : month-1; - } else if (selected == $year) { - year = year-1; - } - value = value; - return; - } + $more.action ++= incrementTrap; + $less.action ++= incrementTrap; //////// // popup behaviour + thisbox.popup ++= static.popupWrite; + thisbox.popdown ++= static.popdownWrite; + var min = function(a, b) { return a>b ? b : a; } // set the surface position of the popbox $popbox.surface_x ++= function() { return min(surface.frame.distanceto(thisbox).x, surface.frame.width - $popbox.width); } $popbox.surface_y ++= function() { return min(surface.frame.distanceto(thisbox).y, surface.frame.height - $popbox.height); } - thisbox.popup ++= function(v) { - static.initDatePicker(thisbox, $datepicker); - thisbox.popup --= callee; - cascade = v; - } - - thisbox.popdown ++= function(v) { - cascade = v; - value = value; - } - /** assign date and popup */ $select.action ++= function(v) { popup = true; $datepicker.day = day; $datepicker.month = month; $datepicker.year = year; - return; + return; } //////// @@ -249,7 +210,8 @@ break; case "enter": if (value==null) { - setToday(); + value = vexi.js.Date.today.as("YMD"); + } else { value = value; } break; @@ -276,7 +238,7 @@ static.init = { fill : .settings..fill }; - static.initDatePicker = function(datefield, datepicker_box) { + var initDatePicker = function(datefield, datepicker_box) { // apply datepicker to box .datepicker(datepicker_box); datepicker_box.minwidth = 200; @@ -285,24 +247,42 @@ /** popdown when monthview wants to popdown */ datepicker_box.action ++= function(v) { - datefield.day = datepicker_box.day; - datefield.month = datepicker_box.month; - datefield.year = datepicker_box.year; + datefield.value = new vexi.js.Date("YMD", datepicker_box.year, datepicker_box.month, datepicker_box.day); cascade = v; } /** popdown when datepicker requests it */ datepicker_box.popdown ++= function(v) { datefield.popdown = true; return; } } + + static.popupWrite = function(v) { + initDatePicker(trapee, trapee.datepicker); + trapee.popup --= callee; + cascade = v; + } + static.popdownWrite = function(v) { + cascade = v; + trapee.value = trapee.value; + } + /** write trap to apply to monthview day/month/year */ static.basicWrite = function(v) { cascade = v; trapee[trapname+"view"].text = trapee[trapname]; } + static.textRead = function() { + return trapee.value+""; + } + + static.textWrite = function(v) { + var d = new vexi.js.Date(); + trapee.value = d.tryParseString(v); + } + /** sets the display format */ - static.textformatWrite = function(v) { + static.displayformatWrite = function(v) { switch (v) { case "DDMMYYYY": trapee.dateview[0] = trapee.dayview; @@ -331,13 +311,22 @@ cascade = v; } + static.textRead = function() { + return trapee.value+""; + } + + static.textWrite = function(v) { + var d = new vexi.js.Date(); + trapee.value = d.tryParseString(v); + } + static.viewsepWrite = function(v) { cascade = v; trapee.dateview[1].text = v; trapee.dateview[3].text = v; } - /** sets the display format */ + /** TODO - REMOVE static.valueformatWrite = function(v) { switch (v) { case "DDMMYYYY": @@ -352,7 +341,7 @@ static.textRead = function() { var s = trapee.valueseparator != null ? trapee.valueseparator : trapee.textseparator; - var f = trapee.valueformat ? trapee.valueformat : trapee.textformat; + var f = trapee.valueformat ? trapee.valueformat : trapee.displayformat; var y = trapee.year; var m = trapee.month; var d = trapee.day; @@ -436,7 +425,7 @@ break; case "string": if (v.toLowerCase() == "today") { - trapee.date = vexi.date(); + value = vexi.js.Date.today.as("YMD"); } else if (trapee.text == v) { break; } else { @@ -448,5 +437,6 @@ } return; } + */ </vexi> Modified: branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/monthfield.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/monthfield.t 2013-07-03 19:25:17 UTC (rev 4535) +++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/monthfield.t 2013-07-16 22:53:04 UTC (rev 4536) @@ -1,12 +1,12 @@ <!-- Copyright 2013 - see COPYING for details [LGPL] --> <vexi xmlns:ui="vexi://ui" - xmlns:conf="vexi.conf" - xmlns:lib="org.vexi.lib" - xmlns:lay="vexi.layout" - xmlns:util="vexi.util" - xmlns:classic="org.vexi.theme.classic" - xmlns="vexi.theme"> + xmlns:conf="vexi.conf" + xmlns:lib="org.vexi.lib" + xmlns:lay="vexi.layout" + xmlns:util="vexi.util" + xmlns:classic="org.vexi.theme.classic" + xmlns="vexi.theme"> <lib:role.popupable /> <lib:role.focusable /> @@ -46,10 +46,15 @@ thisbox.v_popbox = $popbox; thisbox.v_textbox = false; + thisbox.text ++= .datefield..textRead; + thisbox.text ++= .datefield..textWrite; + thisbox.value; ///> vexi.js.Date thisbox.value ++= function(v) { cascade = v; + // value has changed; reject text input + $editview.display = false; //assert(v===null or v instanceof "date"); $month.text = v?.month; $year.text = v?.year; @@ -65,8 +70,8 @@ $month.Press1 ++= selectPart; $year.Press1 ++= selectPart; - var incrementTrap = function(v){ - if(selected==null || value==null) return; + var incrementTrap = function(v) { + if (selected==null || value==null) return; var amount = trapee==$more?1:-1; var period = selected.period; value = value.addPeriod(period, amount); @@ -231,7 +236,6 @@ /** popdown when datepicker requests it */ datepicker_box.popdown ++= function(v) { datefield.popdown = true; return; } } - static.popupWrite = function(v) { initDatePicker(trapee, trapee.datepicker); @@ -244,13 +248,4 @@ trapee.value = trapee.value; } - static.textRead = function() { - return trapee.value+""; - } - - static.textWrite = function(v) { - var d = new vexi.js.Date(); - trapee.value = d.tryParseString(v); - } - </vexi> Modified: branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/quarterfield.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/quarterfield.t 2013-07-03 19:25:17 UTC (rev 4535) +++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/quarterfield.t 2013-07-16 22:53:04 UTC (rev 4536) @@ -52,6 +52,9 @@ thisbox.value ++= function(v) { cascade = v; + // value has changed; reject text input + $editview.display = false; + //assert(v===null or v instanceof "date"); $quarter.text = v?.quarter; $year.text = v?.year; } @@ -66,8 +69,8 @@ $quarter.Press1 ++= selectPart; $year.Press1 ++= selectPart; - var incrementTrap = function(v){ - if(selected==null || value==null) return; + var incrementTrap = function(v) { + if (selected==null || value==null) return; var amount = trapee==$more?1:-1; var period = selected.period; value = value.addPeriod(period, amount); Modified: branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/yearfield.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/yearfield.t 2013-07-03 19:25:17 UTC (rev 4535) +++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/yearfield.t 2013-07-16 22:53:04 UTC (rev 4536) @@ -44,16 +44,21 @@ thisbox.v_popbox = $popbox; thisbox.v_textbox = false; + thisbox.text ++= .datefield..textRead; + thisbox.text ++= .datefield..textWrite; + thisbox.value; ///> vexi.js.Date - thisbox.value ++= function(v) { cascade = v; + // value has changed; reject text input + $editview.display = false; + //assert(v===null or v instanceof "date"); $year.text = v?.year; } //////// - // button actionsmhhht + // button actions thisbox.focused ++= .timefield..focusWrite; thisbox.selected ++= .timefield..selectWrite; @@ -61,8 +66,8 @@ var selectPart = function(v) { selected = trapee; cascade = v; } $year.Press1 ++= selectPart; - var incrementTrap = function(v){ - if(selected==null || value==null) return; + var incrementTrap = function(v) { + if (selected==null || value==null) return; var amount = trapee==$more?1:-1; var period = selected.period; value = value.addPeriod(period, amount); @@ -220,6 +225,7 @@ /** popdown when monthview wants to popdown */ datepicker_box.action ++= function(v) { datefield.day = null; + datefield.month = null; datefield.value = new vexi.js.Date("Y", datepicker_box.year); cascade = v; } @@ -227,7 +233,6 @@ /** popdown when datepicker requests it */ datepicker_box.popdown ++= function(v) { datefield.popdown = true; return; } } - static.popupWrite = function(v) { initDatePicker(trapee, trapee.datepicker); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn