[Gambas-user] How to specify action button at runtime

kobolds kobolds at ...2041...
Wed Jul 15 14:31:02 CEST 2009




Ron Klinkien wrote:
> 
> kobolds wrote:
>> Hi,
>>
>> I try create button at run time but I having trouble to set the click
>> action.
>> here my code
>>
>> DIM m_MaxCol AS Integer = 5
>> DIM m_button AS Button
>> DIM m_MaxBut AS Integer = 18
>> DIM m_Colcnt AS Integer = 0
>> DIM m_Rowcnt AS Integer = 0
>> DIM m_butcnt AS Integer = 0
>> DIM m_Colgap AS Integer = 2
>> DIM m_Rowgap AS Integer = 2
>> DIM m_ButHeight AS Integer = 128
>> DIM m_ButWidth AS Integer = 128
>>
>> WHILE m_butcnt < m_MaxBut
>>
>>   FOR m_Colcnt = 0 TO m_MaxCol - 1
>>     m_button = NEW Button(ScrollView1)
>>     WITH m_button
>>     .x = (m_Colcnt * (m_ButWidth + m_Colgap))
>>     .y = (m_Rowcnt * (m_ButHeight + m_Rowgap))  
>>     .Height = m_ButHeight
>>     .Width = m_ButWidth
>>     .Text = m_Rowcnt & ", " & m_Colcnt
>>   
>>     END WITH 
>>      
>>     
>>     m_butcnt += 1
>>     IF m_butcnt >= m_MaxBut THEN 
>>       BREAK 
>>     ENDIF 
>>   NEXT 
>>
>>   m_Rowcnt += 1
>>
>> WEND 
>>
>> my problem now is how to set the click action and how to know which
>> button
>> is clicking
>>
>>
>>
>>   
> 
> Use this instead:
> 
> m_button = NEW Button(ScrollView1) AS "MyButton"
> 
> Set the .Tag property to something unique:
> 
> .Tag = iUnique
> 
> And then catch the clicks with:
> 
> PUBLIC SUB MyButton_Click()
>   Message.Info("Clicked : " & LAST.tag)
> END
> 
> Regards,
> Ron_2nd.
> 
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge  
> This is your chance to win up to $100,000 in prizes! For a limited time, 
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full
> prize  
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 

By the way , how do I delete all the button in the scroll view. 

-- 
View this message in context: http://www.nabble.com/How-to-specify-action-button-at-runtime-tp24494522p24496913.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list