Alpha DevCon 2018
Results 1 to 24 of 24

Thread: Turning Bubble Help for a Form on and off

  1. #1
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,222

    Default Turning Bubble Help for a Form on and off

    A user asked for a way to turn bubble help for a form off and on. Here is how you can do it using Xbasic.


    First, define these functions as global UDFs.


    Code:
    function captureBubbleHelp as v (a as p, obj as p)
    dim controls as c 
    controls = obj.child_enum("r;e=this.name() + '|'+this.bubble_help")
    controls = *for_each(x,word(x,1,"|"),controls)
    dim count as n 
    count = line_count(controls)
    a.resize(count)
    a.clear()
    dim i as n 
    for i = 1 to count 
    	a[i].name = word(controls,i,crlf())
    	a[i].bubble_help = obj.child(a[i].name).bubble_help
    next i 
    end function

    Code:
    function turnBubbleHelpOff as v (a as p, obj as p )
    
    dim count as n 
    count = a.first_empty("name")-1
    dim i as n
    dim c as p  
    for i = 1 to count 
    	c = obj.child(a[i].name)
    	c.bubble_help = ""
    next i 
    
    
    end function

    Code:
    function turnBubbleHelpOn as v (a as p, obj as p )
    
    dim count as n 
    count = a.first_empty("name")-1
    dim i as n
    dim c as p  
    for i = 1 to count 
    	c = obj.child(a[i].name)
    	c.bubble_help = a[i].bubble_help
    next i 
    
    
    end function


    Then, in the form's Init event put this code:


    Code:
    delete shared a
    dim shared a[0] as p 
    captureBubbleHelp(a,topparent.this)
    This code will create a shared variable that is an array that stores all of the objects that have bubble help and the current value of the bubble help text.

    Then, define a button to turn bubble help off:


    Code:
    turnBubbleHelpOff(a,topparent.this)

    And define this as the button to turn bubble help on again:

    Code:
    turnBubbleHelpOn(a,topparent.this)

  2. #2
    Member
    Real Name
    Mark Campidonica
    Join Date
    Mar 2006
    Location
    California, near Auburn (that's East of Sacramento, in the foothills).
    Posts
    36

    Default Re: Turning Bubble Help for a Form on and off

    Thanks Selwyn,

    This code will be a big help.

    Mark
    Mark Campidonica

  3. #3
    Member
    Real Name
    RMann
    Join Date
    Feb 2006
    Posts
    52

    Default Re: Turning Bubble Help for a Form on and off

    Hi Selwyn,
    will this work with v8? also what do we name the 3 codes/functions?
    you say define these functions as global UDFs... how?

    Thanks. Im new to this. Sorry!
    Last edited by AaronBBrown; 05-09-2007 at 02:17 PM.

  4. #4
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,222

    Default Re: Turning Bubble Help for a Form on and off

    Quote Originally Posted by TheseNutts View Post
    Hi Selwyn,
    will this work with v8? also what do we name the 3 codes/functions?
    you say define these functions as global UDFs... how?

    Thanks. Im new to this. Sorry!
    1. Yes, it will work in V8.

    2. To define a UDF (User Defined Function), you go to the Code tab of the Control Panel. Right click on the white background and select New, Function. In your case a Genie will probably come up asking for the function name and argument (it is possible to turn off this genie, so it might not come up).

    To define the first function, you would enter the function name and arguments in the genie and then press OK. A5 will open the code editor and fill in a function header for you based on what you entered into the genie.

    I suggest that you delete everything that a5 puts into the code editor and just past the first function in and save it.

    Then repeat for the second function.

    (Personally, I find the new function genie annoying, and I always turn it off so that when I create a new function, I go directly to the code editor.)

  5. #5
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,907

    Default Re: Turning Bubble Help for a Form on and off

    Selwyn,

    Do you know if these functions work in prior versions of Alpha as well? It looks like because of the For Each() function, version 6 may be the earliest for it to work.
    Is there a way to emulate the For Each() function in A5V5 ?
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  6. #6
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,222

    Default Re: Turning Bubble Help for a Form on and off

    Quote Originally Posted by MikeC View Post
    Selwyn,

    Do you know if these functions work in prior versions of Alpha as well? It looks like because of the For Each() function, version 6 may be the earliest for it to work.
    Is there a way to emulate the For Each() function in A5V5 ?
    I don't recall in which version *for_each() was introduced, but certainly V5 has the ability to write a loop, and that's just what *for_each() is doing.

    If you understand what the code is doing, it would be possible to make a version of the code that will run in V5.

  7. #7
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,907

    Default Re: Turning Bubble Help for a Form on and off

    Selwyn,

    Thanks for the quick response!

    My mistake--*for_each() can be used in version 5 but not before. It was the For Each ... Next that was introduced in version 6. So it should work in all versions from A5V5 and above--versions prior to this would have to create the loop you referred to that the *for_each() creates.
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  8. #8
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,307

    Default Re: Turning Bubble Help for a Form on and off

    I am wondering how this might be adapted to work from a menu or a toolbar so it could be more global in scope - like in the form editor?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  9. #9
    Member
    Real Name
    RMann
    Join Date
    Feb 2006
    Posts
    52

    Default Re: Turning Bubble Help for a Form on and off

    Thank you...works like a charm ..in v8

  10. #10
    Member
    Real Name
    RMann
    Join Date
    Feb 2006
    Posts
    52

    Default Re: Turning Bubble Help for a Form on and off

    I guess i spoke too quick! now getting this error messsage when i open my form.

    command: a[i].bubble_help = obj.child(a[i].name).bubble_help
    Object is not defined.

    Any suggestions?

  11. #11
    Member
    Real Name
    RMann
    Join Date
    Feb 2006
    Posts
    52

    Default Re: Turning Bubble Help for a Form on and off

    I guess i spoke too quick! now getting this error messsage when i open my form.

    command: a[i].bubble_help = obj.child(a[i].name).bubble_help
    Object is not defined.

    Any suggestions?

  12. #12
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,307

    Default Re: Turning Bubble Help for a Form on and off

    I bumped this thread because I would like to use Selwyn's functions in my right click menu for my forms. It seems like it ought to work as well there as in the OnActivate or OnInit event for the form. But it doesn't - or at least not for me. Would anyone else like to try it and let me know what they may have discovered in how to use them in that context?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  13. #13
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,222

    Default Re: Turning Bubble Help for a Form on and off

    Quote Originally Posted by MoGrace View Post
    I bumped this thread because I would like to use Selwyn's functions in my right click menu for my forms. It seems like it ought to work as well there as in the OnActivate or OnInit event for the form. But it doesn't - or at least not for me. Would anyone else like to try it and let me know what they may have discovered in how to use them in that context?

    it still works, with one change.
    the script that captures the bubble help needs to take into account that html bubble help can have crlf characters in it.

    so one small change is made to the onInit script that captures the bubble help.

    if you look at the form in the attached database, there is bubble help on firstname, lastname and company.

    here is the modified version of the script that captures the initial bubble help


    Code:
    function captureBubbleHelp as v (a as p, obj as p)
    dim controls as c 
    'need to take into account that bubble help can not include crlf. so this turns crlf into spaces.
    controls = obj.child_enum("r;e=this.name() + '|' + stritran(this.bubble_help,crlf(),' ')")
    controls = *for_each(x,word(x,1,"|"),controls)
    dim count as n 
    count = line_count(controls)
    a.resize(count)
    a.clear()
    dim i as n 
    for i = 1 to count 
    	a[i].name = word(controls,i,crlf())
    	a[i].bubble_help = obj.child(a[i].name).bubble_help
    next i 
    end function

  14. #14
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,307

    Default Re: Turning Bubble Help for a Form on and off

    Thanks Selwyn,
    Will this work in the context of a right click menu? I am trying to make it more global in scope so that I don't have to put it in each of my forms OnInit event.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  15. #15
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,222

    Default Re: Turning Bubble Help for a Form on and off

    Quote Originally Posted by MoGrace View Post
    Thanks Selwyn,
    Will this work in the context of a right click menu? I am trying to make it more global in scope so that I don't have to put it in each of my forms OnInit event.
    instead of using the onInit event to capture the existing bubble help into an array, you could eliminate the onInit event and then put the code that captures the existing bubble help in the function that turns off the bubble help.

    this means that every time you turn bubble help off, you first capture the existing bubble help to an array.

  16. #16
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,907

    Default Re: Turning Bubble Help for a Form on and off

    A bit late into this discussion, but what about the exceptions? I mean, to my thinking, it would be rare that someone would want ALL the bubblehelp turned off on a form. I have used bubblehelp as an aid to first time users of an application and also as part of the information of a button's or field's function. The latter I would not want the user to turn off normally, especially if the field or button is not going to be used very often. This is why I have a preferences form in which logical fields are placed that indicate various bubblehelp that can be turned off--but only the ones that I have actually scripted to do this on each form, leaving the ones wanted to be permanent alone....and yes it can be a whole lot of extra script but all are so similar that it is not that hard to incorporate--just tedious. I also do this for warning dialogs--some to remain on and others that can be turned off by the user via the preferences form.

    I suppose Selwyn's script could be modified somewhat to accommodate this also...sort of like how you can leave some windows open when closing all the rest during a backup routine. Some crlf list perhaps of the fields wanted to still have the bubblehelp.

    Not as generic I guess as when you would simply use the function to turn off all the bubblehelp.

    Just thought I'd throw out the idea / exception.
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  17. #17
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,222

    Default Re: Turning Bubble Help for a Form on and off

    Here is a revised version of the script that is now easier to use and completely generic.

    There are now only two functions.

    1. No code has to be added to the form's OnInit event.
    2. There are only two functions now: toggleBubbleHelp() and bubbleHelpState()

    To use these functions, you just call them and pass in a pointer to the form.

    e.g.

    Code:
    toggleBubbleHelp(topparent.this)
    or

    Code:
    dim helpstate as c 
    helpstate = bubbleHelpState(topparent.this)
    helpstate will be set to 'on' or 'off'

    you can easily incorporate the toggleBubbleHelp(topparent.this) command in the form's right click menu.

    Here is the code for the toggleBubbleHelp function:

    Code:
    function toggleBubbleHelp as v (obj as p)
    
    dim sh as n 
    dim sv as p 
    sh = obj.SessionHandle()
    sv = session_variables(sh)
    if eval_valid("sv.__bubbleHelp") = .f. then 
    	dim sv.__bubbleHelp[0] as p 
    end if 
    
    dim BubbleHelpState as c 
    if obj.Child_Enum("r;e=this.bubble_help") = "" then 
    	'if no controls has bubble help, then the state is 'off'
    	BubbleHelpState = "Off"
    else
    	BubbleHelpState = "ON"
    end if 
    
    if BubbleHelpState = "ON" then 
    	turnBubbleHelpOff(obj)
    else
    	turnBubbleHelpOn(obj)
    end if 
    	
    	
    end function 
    
    
    
    
    function turnBubbleHelpOff as v (obj as p )
    
    dim sh as n 
    dim sv as p 
    sh = obj.SessionHandle()
    sv = session_variables(sh)
    dim a as p 
    a = sv.__bubbleHelp
    
    dim BubbleHelpState as c 
    if obj.Child_Enum("r;e=this.bubble_help") = "" then 
    	'if no controls has bubble help, then the state is 'off'
    	BubbleHelpState = "Off"
    else
    	BubbleHelpState = "ON"
    end if 
    
    if BubbleHelpState = "off" then 
    	'if bubble help is already off then just do nothing.
    	exit function 
    end if 
    
    'first, capture the existing bubble help
    a.resize(0)
    captureBubbleHelp(obj)
    
    
    'then, set bubble help for all controls to nothing
    dim count as n 
    count = a.first_empty("name")-1
    dim i as n
    dim c as p  
    for i = 1 to count 
    	c = obj.child(a[i].name)
    	c.bubble_help = ""
    next i 
    end function
    
    
    function turnBubbleHelpOn as v (obj as p )
    
    
    dim sh as n 
    dim sv as p 
    sh = obj.SessionHandle()
    sv = session_variables(sh)
    dim a as p 
    a = sv.__bubbleHelp
    
    dim BubbleHelpState as c 
    if obj.Child_Enum("r;e=this.bubble_help") = "" then 
    	'if no controls has bubble help, then the state is 'off'
    	BubbleHelpState = "Off"
    else
    	BubbleHelpState = "ON"
    end if 
    
    
    if BubbleHelpState = "ON" then 
    	exit function 
    end if 
    
    dim count as n 
    count = a.first_empty("name")-1
    
    dim i as n
    dim c as p  
    for i = 1 to count 
    	c = obj.child(a[i].name)
    	c.bubble_help = a[i].bubble_help
    next i 
    
    
    
    end function
    
    
    
    function captureBubbleHelp as v (obj as p)
    	
    dim sh as n 
    dim sv as p 
    sh = obj.SessionHandle()
    sv = session_variables(sh)
    dim a as p 
    a = sv.__bubbleHelp
    	
    	
    dim controls as c 
    'need to take into account that bubble help can not include crlf. so this turns crlf into spaces.
    controls = obj.child_enum("r;e=this.name() + '|' + stritran(this.bubble_help,crlf(),' ')")
    controls = *for_each(x,word(x,1,"|"),controls)
    dim count as n 
    count = line_count(controls)
    a.resize(count)
    a.clear()
    dim i as n 
    for i = 1 to count 
    	a[i].name = word(controls,i,crlf())
    	a[i].bubble_help = obj.child(a[i].name).bubble_help
    next i 
    end function


    here is the code for the bubbleHelpState() function:

    Code:
    function bubbleHelpState as c (obj as p)
    	
    
    dim sh as n 
    dim sv as p 
    sh = obj.SessionHandle()
    sv = session_variables(sh)
    if eval_valid("sv.__bubbleHelp") = .f. then 
    	dim sv.__bubbleHelp[0] as p 
    end if 
    
    dim BubbleHelpState as c 
    if obj.Child_Enum("r;e=this.bubble_help") = "" then 
    	'if no controls has bubble help, then the state is 'off'
    	BubbleHelpState = "Off"
    else
    	BubbleHelpState = "ON"
    end if 	
    	
    end function

  18. #18
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,307

    Default Re: Turning Bubble Help for a Form on and off

    Selwyn,
    Thanks so much for making this adaptation. When I first saw these functions a year ago, I knew it could be a menu item, just didn't know how. As I have been working on it myself lately, it occurred to me that once the bubble help was off there was nothing to capture again. Even though the bubble help comes back when the form is re-loaded, which in itself seems curious. I guess that's why you write programs and I just use 'em!
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  19. #19
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,307

    Default Re: Turning Bubble Help for a Form on and off

    To use this in the right click menu, I wanted the Bubble Help menu item to appear checked when it is "ON". But the BubbleHelpState appears to be ON only if bubble help exists for the form, otherwise it is OFF even tho the menu item is selected. I tried making the dim statements for BubbleHelpState global in the functions so I could test this for the check mark - but the result is inconsistent. If I dim and initiate the global variable on startup to ON it appears unchecked (until I use it), whereas when it is set to OFF in the menu definition, it appears checked. Other than that though the functions are working great. I suppose I don't actually need the menu item to appear checked - it just seemed like a good idea.

    Oh and for some reason dimming BubbleHelpState as global and intializing it at startup, causes that variable to appear twice in the variable list. Haven't figured out why yet - no typo that I can see, and I deleted the previous functions so only these two are in use. I often dim global variables again and only one instance of them appears in the list with their current value, so this is curious. Since it is actually a function too, perhaps that makes a difference?

    Edit: Well it is obvious by now I am not the brightest bulb in here. To get the menuitem to appear checked, all I need to do is use the FUNCTION BubbleHelpState() and not the value of the variable I have been playing with. I checked the Window Bar menu syntax and that is what it does, so I tried it and it works! So I am guessing I can get rid of the global dim statements since they are not needed for this feature to work as a menu item.
    Last edited by MoGrace; 05-17-2008 at 11:00 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  20. #20
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,784

    Default Re: Turning Bubble Help for a Form on and off

    Robin,

    I was able to get the right click menu to show the check mark for the menu item. See attached. The attached was redone in V7 as this is the v7 forum and believe that is what you are still using. The form in Selwyn's sample did not seem seem to paint properly in v7. He probably made the sample in v11. :)

    Form 'Customer Information2' does not have any bubble help. That is why the menu never gets a check mark.

    I hope this is what you were trying to accomplish.

    EDIT: Big Woops. :o I had started to respond just after lunch and got interupted and forgot to see if the thread had been updated. Oh well, looks like you had already figured it out.
    Last edited by Tim Kiebert; 05-18-2008 at 01:59 AM. Reason: Being behind the times.
    Tim Kiebert
    Geelong Citrus Packers
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  21. #21
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,307

    Default Re: Turning Bubble Help for a Form on and off

    Hi Tim,
    Glad to see you tried it too, I think it is a great little feature to have.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  22. #22
    Member
    Real Name
    Don Lavigne
    Join Date
    Jan 2007
    Location
    New Jersey
    Posts
    223

    Default Re: Turning Bubble Help for a Form on and off

    I'd like to use this function, but I get an "Object is not defined" error. I have duplicated exactly (or so I think) the functions that Selwyn provded. Any ideas??

  23. #23
    Member
    Real Name
    Don Lavigne
    Join Date
    Jan 2007
    Location
    New Jersey
    Posts
    223

    Default Re: Turning Bubble Help for a Form on and off

    UPDATE: The problem is that I am using a form based on a set. When I figure out the solution, I will post it back here.

    Don

    Quote Originally Posted by djldc View Post
    I'd like to use this function, but I get an "Object is not defined" error. I have duplicated exactly (or so I think) the functions that Selwyn provded. Any ideas??

  24. #24
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,307

    Default Re: Turning Bubble Help for a Form on and off

    Quote Originally Posted by djldc View Post
    I'd like to use this function, but I get an "Object is not defined" error. I have duplicated exactly (or so I think) the functions that Selwyn provded. Any ideas??
    Was just looking into this again to see if I could use it in AA 12.

    This error is coming from the line
    obj.child_enum(a[i].name)

    if you check the functions you will see that 'a' was never defined as an array - this should fix it:

    dim a[0] as p

    and in the other line, try setting a var to the array name instead:

    dim nm as c
    nm = a[i].name
    obj.child_enum(nm)

    When using the 'r' parameter in child_enum() it looks into every control on the form and this causes errors too. So I tried setting it to "f=field;e=this.button_help" but this returned nothing. However if r is set to f without specifying the class, you will at least only get objects that actually have button_help.

    In the IW, although I can get a list of bubble help into an array, I cannot get these scripts to actually turn the bubble help on or off anymore.

    Has anyone else got a working script?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

Similar Threads

  1. Turning off the Debugger
    By rfha in forum Alpha Five Version 7
    Replies: 3
    Last Post: 12-28-2005, 04:50 PM
  2. Form Object Bubble help toggle on/off??
    By Scott Emerick in forum Alpha Five Version 6
    Replies: 2
    Last Post: 04-19-2005, 08:14 AM
  3. turning of menu bars
    By Ian_Edwards in forum Alpha Five Version 6
    Replies: 3
    Last Post: 07-29-2004, 03:12 AM
  4. Bubble Help on a Form
    By BRochford in forum Alpha Five Version 5
    Replies: 6
    Last Post: 06-09-2003, 07:57 AM
  5. Scripts are turning me into an alcoholic.
    By Ryan Grasley in forum Alpha Five Version 4
    Replies: 7
    Last Post: 06-05-2002, 05:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •