I know it's not your job to help me debug my programs, but I'm struggling to work out what's going on with some sample code I've created; I can only guess that it's my lack of knowledge about the underlying gui code that's the problem. Either that or I've made a simple and stupid error and I'm looking in the wrong place.
Here's my sample code:
Code: Select all
import "ecere"
class MainWindow : Window
{
caption = $"Make Active Test";
background = { r = 244, g = 248, b = 248 };
borderStyle = fixed;
hasMaximize = false;
hasMinimize = true;
hasClose = true;
tabCycle = true;
hasMenuBar = true;
hasStatusBar = true;
clientSize = { 407, 388 };
position = { 112, 96 };
dontAutoScrollArea = true;
fullRender = true;
SelectionWindow selectionWindow { this };
MainWindow() {
// Header Fields
selectionWindow.selectionHeader.AddField( selectionWindow.selectionHeaderField );
selectionWindow.selectionHeader.currentRow = selectionWindow.selectionHeader.AddRow();
selectionWindow.selectionHeader.SetData( selectionWindow.selectionHeaderField, "Heading" );
// Data Fields
selectionWindow.selection1.AddField( selectionWindow.selection1Field );
selectionWindow.selection1.currentRow = selectionWindow.selection1.AddRow();
selectionWindow.selection2.AddField( selectionWindow.selection2Field );
selectionWindow.selection2.currentRow = selectionWindow.selection2.AddRow();
selectionWindow.selection3.AddField( selectionWindow.selection3Field );
selectionWindow.selection3.currentRow = selectionWindow.selection3.AddRow();
selectionWindow.selection4.AddField( selectionWindow.selection4Field );
selectionWindow.selection4.currentRow = selectionWindow.selection4.AddRow();
}
void selectionMovement (int row, char upDown) {
switch (upDown) {
case 'd' : {
switch (row) {
case 1 : {
selectionWindow.selection2.MakeActive();
break;
}
case 2 : {
selectionWindow.selection3.MakeActive();
break;
}
case 3 : {
selectionWindow.selection4.MakeActive();
break;
}
}
}
case 'u' : {
switch (row) {
case 2 : {
selectionWindow.selection1.MakeActive();
break;
}
case 3 : {
selectionWindow.selection2.MakeActive();
break;
}
case 4 : {
selectionWindow.selection3.MakeActive();
break;
}
}
}
}
return;
}
}
class SelectionWindow : Window
{
caption = $"Selection Window";
background = { r = 235, g = 235, b = 235 };
borderStyle = contour;
tabCycle = true;
size = { 387, 306 };
position = { 10, 13 };
fullRender = true;
int vTop, vGap, vNext, vCheckTop;vTop = 14;vNext = vTop + 24;vGap = 22;vCheckTop = vTop + 24 + 4;
ListBox selectionHeader { this, caption = $"SelectionHeader", inactive = true, size = { 180, 22 }, position = { 13, vTop }, hasVertScroll = false, snapVertScroll = false, rowHeight = 19 };
DataField selectionHeaderField { editable = false, alignment = center, width = 180 };
//
ListBox selection1
{
this, caption = $"Selection1", size = { 180, 22 }, hasVertScroll = false, snapVertScroll = false, rowHeight = 19, position = { 13, vNext };;;;;;;;
bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
{
if(key == down) {
form1.selectionMovement(1, 'd');
}
if(key == up) {
form1.selectionMovement(1, 'u');
}
return true;
}
};
DataField selection1Field { editable = true, alignment = left, width = 180 };
//
ListBox selection2
{
this, caption = $"Selection2", size = { 180, 22 }, hasVertScroll = false, snapVertScroll = false, rowHeight = 19, position = { 13, ( vNext += vGap ) };;
bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
{
if(key == down) {
form1.selectionMovement(2, 'd');
}
if(key == up) {
form1.selectionMovement(2, 'u');
}
return true;
}
};
DataField selection2Field { editable = true, alignment = left, width = 180 };
//
ListBox selection3
{
this, caption = $"Selection3", size = { 180, 22 }, hasVertScroll = false, snapVertScroll = false, rowHeight = 19, position = { 13, ( vNext += vGap ) };
bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
{
if(key == down) {
form1.selectionMovement(3, 'd');
}
if(key == up) {
form1.selectionMovement(3, 'u');
}
return true;
}
};
DataField selection3Field { editable = true, alignment = left, width = 180 };
//
ListBox selection4 { this, caption = $"Selection4", size = { 180, 22 }, position = { 13, ( vNext += vGap ) }, hasVertScroll = false, snapVertScroll = false, rowHeight = 19 };
DataField selection4Field { editable = true, alignment = left, width = 180 };
}
MainWindow form1 {};
Stepping through with the debugger appears to follow the correct logic, but what is then displayed doesn't follow what should be shown. Also, removing the break statements from the 'case' results in different behaviour, even though the debugger follows the same steps as before.
It's probably me, but I'd like to make sure...