2
$\begingroup$

I'm trying to write a timetable application. (The activity blocks are to be resizable and reorderable.) A problem I have run into, which might be a showstopper for this approach, is that entering times (minutes) and activities into the InputFields requires multiple clicks into the graphic. Is there a way make the InputFields as accessible as the buttons? (Only the "+" buttons work at the moment.)

Clear[timetable, entry, del, add, activity, mins]

newentry[num_, ypos_] := Inset[Graphics[{ColorData[24][num],
    Rectangle[{0, 0}, {400, -100}],
    Inset[Button["-", del[num]], {40, -12}],
    Inset[InputField[Dynamic[mins[num]], Number,
      FieldSize -> 4], {40, -40}],
    Inset[InputField[Dynamic[activity[num]], String,
      BaseStyle -> {FontColor -> Black, FontSize -> 22},
      FieldSize -> 8], {200, -40}],
    Inset[Button["+", add[num]], {40, -85}],
    Inset[Button["Up"], {360, -12}],
    Inset[Button["Dn"], {360, -85}]
    }, PlotRange -> {{0, 400}, {0, -100}}, ImageSize -> 400],
  {0, ypos}, {0, 0}, {400, 100}]

add[prev_] := Module[{},
  num = prev + 1;
  ypos = entry[prev][[-3, 2]] - 100;
  entry[num] = newentry[num, ypos]]

num = 1;
entry[num] = Inset[Graphics[{ColorData[24][num],
     Rectangle[{0, 0}, {400, -100}],
     Inset[Button["-", del[1]], {40, -12}],
     Inset[InputField[Dynamic[mins[1]], Number,
       FieldSize -> 4], {40, -40}],
     Inset[InputField[Dynamic[activity[1]], String,
       BaseStyle -> {FontColor -> Black, FontSize -> 22},
       FieldSize -> 8], {200, -40}],
     Inset[Button["+", add[1]], {40, -85}],
     Inset[Button["Up"], {360, -12}],
     Inset[Button["Dn"], {360, -85}]
     }, PlotRange -> {{0, 400}, {0, -100}}, ImageSize -> 400],
   {0, 0}, {0, 0}, {400, 100}];
timetable = Dynamic[Graphics[{Yellow,
     Rectangle[{0, 0}, {400, -500}],
     Array[entry, num]
     }, PlotRange -> {{0, 400}, {0, -500}}, ImageSize -> 400],
   TrackedSymbols :> {num}];

timetable

enter image description here

$\endgroup$
2
1
$\begingroup$

Deploy seems to do the trick.

timetable = Deploy[Dynamic[Graphics[{Yellow,
      Rectangle[{0, 0}, {400, -500}],
      Array[entry, num]
      }, PlotRange -> {{0, 400}, {0, -500}}, ImageSize -> 400],
    TrackedSymbols :> {num}]];
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.