Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: form as dialog panel?

  1. #21
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,295
    of course events work. The whole of the app builder uses this framework. Look at the example apps provided that, have custom sections. Look at, the dialog button delegates. These will help you. This framework works with all supported scripting languages not just Lianja/VFP.

    Lianja/VFP is object oriented. You can subclass UI components and override methods.

    Please provide some sample code that “does not work” then we can advise you what you are doing wrong.

    yes you can assign object variables. You just did and it shows it as a grid object.

    Cut and paste this code into the editor and run it. These framework classes can be used with Lianja/VFP, JavaScript, Python and PHP. There are examples provided in the distro.

    Code:
    define class mybuttonclass as commandbutton
        proc click
            ? "you clicked mybuttonclass"
        endproc
    endclass
    
    // create a form, add a container anmd add buttons to the container
    private myform = createObject("form")
    myform.layout = "vertical"
    myform.addObject("mycont", "container")
    mycont.anchor = 4096
    mycont.backcolor = "lightgreen"
    
    // you can add a base class from the UI framework classes
    mycont.addObject("mybutton", "commandbutton")
    ? mybutton
    mybutton.move(10,10,100,60)
    mybutton.caption = "click me"
    
    // notice how you can assign event handlers dynamically
    proc myclickhandler()
        ? "clicked"
    endproc
    mybutton.click = myclickhandler
    
    // you can add classes that are derived from other classes
    mycont.addObject("mybutton2", "mybuttonclass")
    mybutton2.move(10,100,100,60)
    mybutton2.caption = "Click this"
    ? mybutton2
    
    // show the modal form
    myform.show(1)
    Name:  Screen Shot 2020-09-25 at 12.16.04 PM.jpg
Views: 34
Size:  56.8 KB
    Last edited by barrymavin; 2020-09-25 at 06:19.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  2. #22
    Senior Member
    Join Date
    Oct 2012
    Posts
    213
    no events are trigged while form is running
    Code:
    private    m_grid										// with local variable doesn't work 	
    define class typein as textbox
    	proc keypress
    		Lianja.showMessage(this.value)
    	endproc
    	proc click
    		Lianja.showMessage(upper(this.value))
    	endproc
    enddefine
    
    define class mypanel as container
    	anchor = 1+1024+2048
    	layout = 2
    	mygrid = .null.
    	add object mycanvas as container with anchor=1024+2048,layout=2
    	add object myinput as typein custom
    
    	proc grid_click 
    		parameters obj
    		Lianja.showMessage(etos(obj))
    	endproc
    	
    	proc col_click 
    		parameters nCol											// pcount() = 0
    		private oGrid, cVar
    		oGrid = this.mygrid[1]									//? oGrid = this.mygrid isn't enough
    		cVar = oGrid.columns(1).controlSource
    		Lianja.showMessage(etos(&cVar))
    	endproc
    	
    	proc head_click 
    		parameters nCol
    		private oGrid, cVar
    		oGrid = this.mygrid[1]										//?
    		cVar = oGrid.columns(nCol).caption
    		Lianja.showMessage(cVar)
    	endproc
    	
    	proc afterRowColChange 
    		parameters nRow
    		private oGrid, cVar
    		oGrid = this.mygrid										//!
    //		oGrid = m_grid
    		cVar = oGrid.columns(1).controlSource
    		Lianja.showMessage(etos(&cVar))
    	endproc
    
    	proc beforeRowColChange 
    		parameters nCol
    		private oGrid, cVar
    		oGrid = this.mygrid[1]										//!
    		cVar = oGrid.columns(nCol).controlSource
    		Lianja.showMessage(etos(&cVar))
    	endproc
    
    enddefine
    define class mywindow as form
    	add object panel as mypanel custom
    enddefine
    
    m_window = createobject("mywindow")
    m_form = m_window.panel
    m_form.SetStretchfactor(0,10)
    m_form.SetStretchfactor(1,01)
    
    use southwind!customers
    
    m_grid = m_form.mycanvas.browse("browse fields contactname, companyname, customerid noedit nomodify ","customers")
    m_form.mygrid = m_grid
    //oGrid = m_grid																	//!!!!
    //m_form.mygrid = oGrid															//!!!!
    m_grid.bindevents(m_grid,"click",m_form,"grid_click")
    m_grid.bindevents(m_grid,"mousedblclick",m_form,"grid_click")
    m_grid.bindevents(m_grid,"rightclick",m_form,"grid_click")
    m_grid.bindevents(m_grid,"atferRowColChange",m_form,"atferRowColChange")
    m_grid.bindevents(m_grid,"beforeRowColChange",m_form,"beforeRowColChange")
    m_grid.columns(1).bindevents(m_grid.columns(1),"click",m_form,"col_click")
    m_grid.columns(1).bindevents(m_grid.columns(1),"mousedblclick",m_form,"col_click")
    m_grid.columns(1).bindevents(m_grid.columns(1),"rightclick",m_form,"col_click")
    //m_grid.columns(1).header1.bindevents(m_grid.columns(1).header1,"click",m_form,"head_click")				// header doesn't have bindevents method?
    //m_grid.columns(1).header1.bindevents(m_grid.columns(1).header1,"mousedblclick",m_form,"head_click")
    //m_grid.columns(1).header1.bindevents(m_grid.columns(1).header1,"rightclick",m_form,"head_click")
       
    m_grid.activeRow = 2
    m_grid.activeRow = 3											// no event fired
    
    raiseevent(m_grid,"click")										// ineffective
    raiseevent(m_grid,"rightclick")									// ineffective
    //raiseevent(m_grid,"mousedblclick")							// causes crash
    //raiseevent(m_grid,"atferRowColChange")						// causes crash
    raiseevent(m_grid,"beforeRowColChange")							// ineffective
    raiseevent(m_grid.columns(1),"click")					//works
    sleep 1
    raiseevent(m_grid.columns(1),"rightclick")				//works
    sleep 1
    //raiseevent(m_grid.columns(1),"mousedblclick")					// causes crash
    //sleep 1
    raiseevent(m_grid.columns(1).header1,"click")					// ineffective
    raiseevent(m_grid.columns(1).header1,"rightclick")				// ineffective
    //raiseevent(m_grid.columns(1).header1,"mousedblclick")			// causes crash
    //sleep 1
    m_grid.columns(1).click = textinput
    m_grid.keypress = keyinput
    
    raiseevent(m_grid.columns(1),"click")							//works   ... but ...
    sleep 1
    raiseevent(m_grid,"keypress")									//works   ... but ...
    sleep 1
    
    
    m_form.myinput.value = "type or click ..."
    raiseevent(m_form.myinput,"keypress")					//works
    sleep 1
    raiseevent(m_form.myinput,"click")						//works
    sleep 1
    m_form.myinput.click = textinput
    m_form.myinput.keypress = textinput
    raiseevent(m_form.myinput,"click")						//works
    sleep 1
    raiseevent(m_form.myinput,"keypress")					//works
    sleep 1
    
    m_form.myinput.setfocus()
    m_window.resize(600,400)
    m_window.visible = .t.
    m_window.show(1)
    
    
    procedure textinput()
    	local lvl, evn, cv, cc
    	lvl = dolevel()
       	evn = procname(lvl-1)
    //	if type("this.name") != "U"								// causes crash if called from grid event
        if at(".",this.controlsource) = 0 
    		Lianja.showMessage("called from "+etos(this.name)+"("+evn+")"+":"+etos(this.value))
    	else
    		cv = etos(m_grid.activerow) + " @ " + etos(m_grid.recno) 
    		cc = &(this.controlsource)	
    		lianja.showMessage(cv+" : "+cc)
    	endif
    return
    
    procedure keyinput()
    	lianja.showMessage(etos(lastkey()))
    return

  3. #23
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,295
    Did you read the code I wrote and test it as I suggested?

    If you have issues, rather than post your observations here submit a ticket for each issue on a separate ticket and they will be investigated.

    Nevertheless there are problems with your code which are causing crashes. That should not occur and I have fixed these.

    1. typo afterrowcolchange not afferRowColChange
    2. there is no mousedblclick event its dblclick
    3. m_grid.activeRow was not calling the afterRowColChange event. This has been fixed.
    Last edited by barrymavin; 2020-09-25 at 13:38.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #24
    Senior Member
    Join Date
    Oct 2012
    Posts
    213
    yes I have read and used your suggestions, many thanks! I wonít send a ticket until I know thereís a bug or Iím just misusing Liana. (eg I'm typing a typo incorrectly ... although it shouldn't cause a crash yet ... I'm sorry), or I just don't know it.
    I didn't find dblclick event in the doc: https://www.lianja.com/doc/index.php...:Common_Events, but thanks, this is the only event I can handle in the grid object at the moment.
    The main problem, however, is the lack of other events ...

    Code:
    private    m_grid										// with local variable doesn't work 	
    define class typein as textbox
    	proc keypress
    		Lianja.showMessage(this.value)
    	endproc
    	proc click
    		Lianja.showMessage(upper(this.value))
    	endproc
    enddefine
    
    define class mypanel as container
    	anchor = 1+1024+2048
    	layout = 2
    	mygrid = .null.
    	add object mycanvas as container with anchor=1024+2048,layout=2
    	add object myinput as typein custom
    
    	proc grid_click 
    		parameters obj
    		Lianja.showMessage(etos(obj))
    	endproc
    	
    	proc col_click 
    		parameters nCol											// pcount() = 0
    		private oGrid, cVar
    		oGrid = m_grid
    		cVar = oGrid.columns(1).controlSource
    		Lianja.showMessage(etos(&cVar))
    	endproc
    	
    	proc head_click 
    		parameters nCol
    		private oGrid, cVar
    		oGrid = m_grod
    		cVar = oGrid.columns(nCol).caption
    		Lianja.showMessage(cVar)
    	endproc
    	
    	proc afterRowColChange 
    		parameters nRow
    		private oGrid, cVar
    		oGrid = m_grid
    		cVar = oGrid.columns(1).controlSource
    		Lianja.showMessage(etos(&cVar))
    	endproc
    
    	proc beforeRowColChange 
    		parameters nCol
    		private oGrid, cVar
    		oGrid = m_grid
    		cVar = oGrid.columns(nCol).controlSource
    		Lianja.showMessage(etos(&cVar))
    	endproc
    
    enddefine
    define class mywindow as form
    	add object panel as mypanel custom
    enddefine
    
    m_window = createobject("mywindow")
    m_form = m_window.panel
    m_form.SetStretchfactor(0,10)
    m_form.SetStretchfactor(1,01)
    
    use southwind!customers
    
    m_grid = m_form.mycanvas.browse("browse fields contactname, companyname, customerid noedit nomodify ","customers")
    
    m_grid.columns(1).click = textinput
    m_grid.keypress = keyinput
    m_grid.columns(1).dblclick = mouseinput2 
    
    m_form.myinput.value = "type or click ... to try events"
    m_form.myinput.click = textinput
    m_form.myinput.keypress = textinput
    m_form.myinput.dblclick = textinput2
    m_form.myinput.setfocus()
    
    m_window.resize(600,400)
    m_window.visible = .t.
    m_window.show(1)
    
    
    procedure textinput()
    	parameters clk
    	local lvl, evn, cv, cc, ca
    	lvl = dolevel()
       	evn = procname(lvl-1)
    	ca = iif(pcount()>0," - DBL", "")
    //	if type("this.name") != "U"								// causes crash if called from grid event
        if at(".",this.controlsource) = 0 
    		Lianja.showMessage("called from "+etos(this.name)+"("+evn+")"+":"+etos(this.value)+ca)
    	else
    		cv = etos(m_grid.activerow) + " @ " + etos(m_grid.recno) 
    		cc = &(this.controlsource)	
    		lianja.showMessage(cv+" : "+cc+ca)
    	endif
    return
    
    proc textinput2()
    	=textinput(2)
    endproc
    
    procedure keyinput()
    	if pcount() > 0
    		lianja.showMessage(chr(lastkey())
    	else
    		lianja.showMessage(etos(lastkey()))
    	endif
    return
    
    proc keyinput2
    	=keyinput(2)
    endproc
    
    proc mouseinput
    	if pcount() > 0
    		lianja.showMessage("column Click")
    	else
    		lianja.showMessage("browse Click")
    	endif
    endproc
    
    proc mouseinput2
    	=mouseinput(2)
    endproc

  5. #25
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,295
    What events are you referring to. Column headers? Columns? If something is not supported that you feel is important in your use case then please submit an enhancement request.

    Yes a typo in the event name should not cause a crash and as I said it has been fixed.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  6. #26
    Senior Member
    Join Date
    Oct 2012
    Posts
    213
    can I find a list of events actually supported somewhere? For each object, the doc contains: "This class supports the Common Events plus the following:" (btw. Same problem with common properties and common methods as well)
    thank you for your help!

  7. #27
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    6,295
    I have corrected "mousedblclick" in the doc.

    The doc is where these are detailed. If the doc is missing some things or incomplete in your view please submit a ticket.

    Can you explain to me what events you require on what classes that are missing. Submit tickets.

    Rather than confuse the issue with bindEvents() and raiseEvent() try and declare your event handlers in classes or dynamic assignments. This will help determine better.

    Your use of "events" is purely in your custom code as these are normally handled in delegates which are not exactly the same thing.
    Last edited by barrymavin; 2020-09-26 at 03:34.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us