|
Post by colinmac on May 14, 2011 12:34:02 GMT -5
Hello,
I am developing a programme that uses a main project and several child projects, each to manage a seperate table in a database. I have found that pressing the enter key when using a textbox can lead to strange behavour. The code below uses input statements, but the behaviour is the same with textboxes.
Here is the main, calling, programme called 'mainproblem.bas'
run "firstchild" , #firstchild run "secondchild", #secondchild wait
[firstClicked] dummy = runbanner() render #firstchild wait
[secondClicked] dummy = runbanner() render #secondchild wait
function runbanner() cls html "<h3> my problem children</h3> " button #firstchildbutton, "first child process", [firstClicked] button #secondchildbutton, "second child process", [secondClicked] html "<br />" end function
now the two child projects. firstchild.bas
rem firstchild code [loop] input " first child name? " ; fchild goto [loop] wait
and secondchild.bas
rem secondchild code [loop] input " second child name? " ; schild goto [loop] wait
Using the 'accept' button to complete a name entry works as I would expect. Pressing 'enter' to complete an entry in 'firstchild' cancels the entry. Not what I would expect but Okish. Doing the same in 'secondchild' switches everything to 'firstchild'.
Does anyone know what is going on here, and how to avoid it?
Thanks, Colin
|
|
mmiscool
Full Member
 
Send me a message if you want to help with a WEB OS project
Posts: 106
|
Post by mmiscool on May 14, 2011 22:42:48 GMT -5
I do not believe you can use the input command in embedded objects. Try making a textbox and a submit button.
-Mike
|
|
|
Post by StefanPendl on May 15, 2011 7:35:17 GMT -5
I had to change the following to make the program run:
run "firstchild" , #firstchild run "secondchild", #secondchild dummy = runbanner() wait
Now the problem seems to be that we are on a form, which has several buttons, but all are currently submit buttons and there is none defined as the default button. This seems to make the first button the default, which is the one launching the first child.
Being able to set a button as the default would allow the code to work, but I have not done this yet and there is no method for this in RB.
|
|
|
Post by kokenge on May 15, 2011 11:36:12 GMT -5
Hmmm?? I tried your code and as far as I can tell it works?? I removed the first wait, and placed a path on the RUN. But other than that it worked great..
incdir$ = DefaultDir$ + "\projects\test_project\"
run incdir$;"firstchild.bas" , #firstchild run incdir$;"secondchild.bas", #secondchild
[firstClicked] dummy = runbanner() render #firstchild wait
[secondClicked] dummy = runbanner() render #secondchild wait
function runbanner() cls html "<h3> my problem children</h3> " button #firstchildbutton, "first child process", [firstClicked] button #secondchildbutton, "second child process", [secondClicked] html "<br />" end function
You may also be interested in this: runbasic.wikispaces.com/parentChild
|
|
|
Post by colinmac on May 15, 2011 12:12:01 GMT -5
Hello All,
First an apology. I cut and pasted the code fragments from my text editor, but the first line of the first programme - dummy = runbanner() - did not make the paste, and I did not spot it before posting. The code boxes have such a tiny font and my eyes are getting older all the time.
Thank you all for the quick replies. I will study them and let you know how I get on.
Colin
|
|
|
Post by colinmac on May 17, 2011 18:02:04 GMT -5
Hello,
I think I have sorted out what is happening. It has nothing to do with children and parents as it turns out.
Stefan is right. RB appears to handle input elements as if they are input elements of an html form. As would happen in standard html, pressing enter in a 'text' type of input field submits the form.
By default, the 'action' field of the form appears to be the handler routine for the first button in the form, and that is where program flow goes to. But all this is not intuitive and took me by surprise!
The workaround then becomes comparatively simple. Make the first visible button on the web page point to a handler that knows where in the program the user is and renders the appropriate objects. I have called this button 'refresh' in my own application.
From a programmers perspective, if pressing 'enter' in a texbox (or input box) causes programme flow to jump somewhere else, this should be made clearer to the programmer. It would be even better of the programmer could control that jump.
Maybe textboxes should have event handlers, like buttons do, that are fired on pressing enter. The syntax would be something like: Texbox #mybox , "my prompt" , length, [myaction]
How about it, Carl?
Colin
|
|
jerry
Junior Member

Posts: 83
|
Post by jerry on Jul 2, 2014 7:18:41 GMT -5
Colinmac!
I hope you still visit this forum. Yes, an event handler on textbox would be very useful. I am still trying to understand your work around. WOuld you ahve any code to share as an example?
Jerry
|
|
|
Post by colinmac on Jul 4, 2014 18:02:54 GMT -5
Hi Jerry,
I will have a look at this ocde and get back to you in a day or so.
Colin
|
|
|
Post by colinmac on Jul 6, 2014 12:54:21 GMT -5
Hi Gerry,
this is a simple as I can make my code. Make this your main project file, and save in your project directory. In this example, the project is called demoforjerry.
rem new demo project incdir$ = DefaultDir$ + "\projects\demoforjerry_project\" run incdir$;"route1.bas" , #route1 run incdir$;"route2.bas", #route2 run incdir$;"route3.bas" , #route3 call runbanner wait
[route1clicked] #handleholder = #route1 goto [refresh] wait [route2clicked] #handleholder = #route2 goto [refresh] wait
[route3clicked] #handleholder = #route3 goto [refresh] wait
[endAll] cls end
[refresh] call runbanner render #handleholder wait
sub runbanner cls button #refresh, "" , [refresh] rem #refresh setid("refreshbutton")
button #button1, "route 1", [route1clicked] button #button2, "route 2", [route2clicked] button #button3, "route 3", [route3clicked] button #last, "end programme", [endAll]
end sub
Prepare your child processes and basic programs and store them in the same directory as the main project. In this case, they are route1.bas, route2.bas and route3.bas (I am watching the Tour de France in Yorkshire this week). Here is the route1.bas program.
rem demo for jerry route1 print "this is route 1" ; textbox #route1box,"route 1", 20
When the main program is run the subroutine runbanner creates the navigation buttons and waits for a button to be pressed. When a button is pressed, the identity of the sub-program selected is stored in the variable #handleholder. The [refresh] routine is then called. This redraws the menu and then renders the selected sub-program.
The key to this (I think, It is some time since I worked on this) is the 'refresh' button in the navigation menu. This must be the first widget visible after the cls. This button must have as it's action the [refresh] routine that draws the actual subprogram required afresh. This button (the first one after the cls) appears to be the the default location that runbasic identifies when a textbox etc is fired.
There may be better ways to do this but this does work. It maght be slow for programs that have a lot of graphics to draw, but for text based stuff is seems OK and data is preserved as far as I can tell.
I hope it is helpful.
Colin McMurchie
|
|
jerry
Junior Member

Posts: 83
|
Post by jerry on Sept 9, 2014 18:44:22 GMT -5
COLIN!
Thank you!
|
|