Page 1 of 1

Input on one dialog to display on different dialog

Posted: Thu Mar 16, 2006 9:37 pm
by reinaldocrespo
Hi.

Me again asking for help.

I need to allow input into gets from another dialog that simply displays the numeric keypad. Here is that image:
[/img]
http://www.structuredsystems.com/pictur ... screen.jpg
[/img]
Here is my code:

Code: Select all

... in ::odlg definition (main dialog)
	REDEFINE GET aGet[ 3] VAR ::oTrg:VarBP ID 103 OF ::ofld:aDialogs[ 1 ] Picture "999/999" VALID( ColorIfEmpty( aget[ 3 ] ) )
	aget[ 3 ]:bGotFocus := {|| ::oActive := aGet[ 3 ] }
...
... now inside NumKeyPad Dlg definition
local oSelf		:= Self
		DEFINE DIALOG oSelf:oKeyPadDlg RESOURCE "NUM_KEYPAD" OF oSelf:oDlg BRUSH oBrush
...
		REDEFINE BTNBMP oBtn[12] ID 112 RESOURCE "NUM_RIGHT" OF oSelf:oKeyPadDlg ACTION oSelf:Insert( VK_RIGHT ) NOBORDER
		REDEFINE BTNBMP oBtn[13] ID 113 RESOURCE "NUM_ENTER" OF oSelf:oKeyPadDlg ACTION oSelf:Insert( VK_TAB ) NOBORDER
		aEval( obtn, { |e|e:lTransparent := .t. } )
		ACTIVATE DIALOG oSelf:oKeyPadDlg NOWAIT ON INIT oSelf:oDlg:SetFocus()
...
*-------------------------------------------------------------------------------------------------------------------------------
METHOD Insert( xKey ) CLASS TTriage
Local nFocus	:= ::oDlg:oCtlFocus:nOption

	if nFocus == 1 .and. ValType( ::oActive ) <> "U"
		::odlg:SetFocus()
		FwKeyboard( ::oActive, xKey ) //thanks J.Bott
	Endif

RETURN NIL
It almost works.

The problem is in method Insert. By setting focus to ::odlg (main dialog), the cursor goes to the very first get on the dialog. If not setting focus to ::odlg, then nothing gets inputed into the gets.

Help please?

Reinaldo.[/url]

Posted: Thu Mar 16, 2006 9:59 pm
by James Bott
Reinaldo,

I think we are going to need a small self-contained example.

Also I do not understand why you are using a local oSelf:

local oSelf := Self
DEFINE DIALOG oSelf:oKeyPadDlg RESOURCE "NUM_KEYPAD" OF oSelf:oDlg BRUSH oBrush

oSelf:oKeyPadDlg is the same as ::oKeyPadDlg. You don't need a local. Perhaps you are confused about this?

James

Posted: Thu Mar 16, 2006 11:27 pm
by reinaldocrespo
James;

Thank you for answering. Good question on the oself. I have discovered that:

Code: Select all

		ACTIVATE DIALOG ::oKeyPadDlg NOWAIT ON INIT ::oDlg:SetFocus()
Will cause an error at run time. ::oDlg is presumed to belong to the tdialog class at runtime. So I get around that problem by referencing as oself:oDlg.
Application
===========
Path and name: F:\mp\triage.exe (32 bits)
Size: 2,423,808 bytes
Time from start: 0 hours 0 mins 7 secs
Error occurred at: 03/16/2006, 18:20:09
Error description: Error BASE/1004 Message not found: TDIALOG:ODLG
It will cause the same runtime error here:

Code: Select all

		REDEFINE BTNBMP oBtn[13] ID 113 RESOURCE "NUM_ENTER" OF ::oKeyPadDlg ACTION ::Insert( VK_TAB ) NOBORDER
Application
===========
Path and name: F:\mp\triage.exe (32 bits)
Size: 2,423,808 bytes
Time from start: 0 hours 0 mins 11 secs
Error occurred at: 03/16/2006, 18:23:15
Error description: Error BASE/1004 Message not found: TBTNBMP:INSERT
So I get around that problem with oself:Insert( VK_TAB ). Pretty soon I'm using oSelf anywhere I'm defining or redefining just to make sure that the pre-processor does not make the wrong association.

I will try to build a self-contained example. But if you look at the picture, you pretty much get an idea of what I'm trying to do.



Reinaldo

Posted: Fri Mar 17, 2006 2:35 am
by James Bott
Reinaldo,

>Will cause an error at run time. ::oDlg is presumed to belong to the tdialog class at runtime. <

Ah, yes. That is because the preprocessor passes self in the codeblock. I think you can get around that problem by defining the codeblock yourself.

> I will try to build a self-contained example. But if you look at the picture, you pretty much get an idea of what I'm trying to do.<

Oh, I see what you are trying to do, but I can't run your code example to test it.

James[/u]

Posted: Fri Mar 17, 2006 4:11 am
by reinaldocrespo
James;

I'm sure you are dieing to ask, so let me be quite frank. I'm aware that this type of input interface is not as efficient as doing the input via the keyboard. Originally I was reluctant to implement a visual keypad for data entry. But was later persuaded by the customer for two reasons (besides the fact that the customer is always right):

1. The operator will be using a touch screen to do the input. That changes the panorama.

2. The people that make purchasing decisions are strongly influenced by touch screen graphical input screens. They don't understand that some times less is more.

I have tried to simplify the code as much as possible and have uploaded a sample .prg + .rc zipped into triage.zip and is available from

www.structuredsystems.com/pictures/screenpicture/

It is "compilable" with fw's buildx.bat.

You'll notice that it works well except for numeric and date variable types. Haven't figure out why.


Reinaldo.

Posted: Fri Mar 17, 2006 7:01 am
by James Bott
Reinaldo,

I have downloaded your sample and have it running, but its late and I have to drive all day tomorrow, so I will look at when I return.

James

Posted: Fri Mar 17, 2006 8:06 am
by Enrico Maria Giordano
reinaldocrespo wrote:You'll notice that it works well except for numeric and date variable types. Haven't figure out why.
Because numeric and date restores to the first position on gotfocus.

EMG

Posted: Fri Mar 17, 2006 11:49 am
by reinaldocrespo
Enrico;

Hi.

Thank you for the reply.

Yes, I did notice that once the get control gets focus it does restore to the first position. Perhaps there is a work-around to this?

Reinaldo.